Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2012
    Posts
    8
    Plugin Contributions
    0

    Default Can I disable 'javascript:void' in categories to preserve category click?

    Hey there,

    I would like to preserve in my sidebar navigation the ability to click at anytime the subcategory to be able to go back to the product array (i.e. the page with all the products photos in their respective sub-category). Right now when a customer is in a product detail page, the sidebar navigation link to go back is turned off with a "javascript:void(0)"

    Since I'm not very good with php, how would I change the line of code in the "categories_ul_generator.php" file so it doesn't create a null link? Thanks for any help!

    Code:
      function buildBranch($parent_id, $level = 0, $cpath = '') {
        global $cPath;
        $result = "\n".sprintf($this->parent_group_start_string, str_repeat(' ', $level*4))."\n";
        if (isset($this->data[$parent_id])) {
          foreach ($this->data[$parent_id] as $category_id => $category) {
            $result .= sprintf($this->child_start_string, str_repeat(' ', $level*4+2));
            if (isset($this->data[$category_id])) {
              $result .= $this->parent_start_string;
            }
            if ($level == 0) {
              $result .= $this->root_start_string;
              $new_cpath  = $category_id;
            } else {
              $new_cpath = $cpath."_".$category_id;
            }
            if ($cPath == $new_cpath) {
              $result .= '<a href="javascript:void(0)" class="on">'; // highlight current category & disable link
            } else {
              $result .= '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $new_cpath) . '">';
            }
            $result .= $category['name'];
            if (SHOW_COUNTS == 'true' && ((CATEGORIES_COUNT_ZERO == '1' && $category['count'] == 0) || $category['count'] >= 1)) {
              $result .= CATEGORIES_COUNT_PREFIX . $category['count'] . CATEGORIES_COUNT_SUFFIX;
            }
            $result .= '</a>';
            if ($level == 0) {
              $result .= $this->root_end_string;
            }
            if (isset($this->data[$category_id])) {
              $result .= $this->parent_end_string;
            }
            if (isset($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
              $result .= $this->buildBranch($category_id, $level+1, $new_cpath);
              $result .= sprintf($this->child_end_string, str_repeat(' ', $level*4+2))."\n";
            } else {
              $result .= sprintf($this->child_end_string, '')."\n";
            }
          }
        }
        $result .= sprintf($this->parent_group_end_string, str_repeat(' ', $level*4))."\n";
        return $result;
      }

  2. #2
    Join Date
    Jun 2012
    Posts
    8
    Plugin Contributions
    0

    Default Re: Can I disable 'javascript:void' in categories to preserve category click?

    I tried just replacing this line:

    Code:
              $result .= '<a href="javascript:void(0)" class="on">'; // highlight current category & disable link
    with the next line:

    Code:
             $result .= '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $new_cpath) . '">';
    But this only works for one page, and then it starts spewing code! Any ideas? I don't think I can just remove that portion because it is actually building a link...

  3. #3
    Join Date
    Jun 2012
    Posts
    8
    Plugin Contributions
    0

    Default Re: Can I disable 'javascript:void' in categories to preserve category click?

    Nobody has had to do this before?

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Can I disable 'javascript:void' in categories to preserve category click?

    This is not part of core Zen Cart, so you will need to identify exactly where you got the code/mod and probably let us see it live if we are to advise on how best to change it.

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Can I disable 'javascript:void' in categories to preserve category click?

    My first guess at what may work would be essentially as you said you did, but preserving the class so the current category remains highlighted:
    PHP Code:
            if ($cPath == $new_cpath) {
              
    $result .= '<a href="' zen_href_link(FILENAME_DEFAULT'cPath=' $new_cpath) . '" class="on">'// highlight current category 
            
    } else {
              
    $result .= '<a href="' zen_href_link(FILENAME_DEFAULT'cPath=' $new_cpath) . '">';
            } 

  6. #6
    Join Date
    Jun 2012
    Posts
    8
    Plugin Contributions
    0

    Default Re: Can I disable 'javascript:void' in categories to preserve category click?

    Yessir that worked. I did add the class before, but I have a feeling I didn't follow the correct php procedure for including the class correctly! Thank you so much for you help!

 

 

Similar Threads

  1. Javascript:void(0) error when adding image with ckeditor
    By huntleybill in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 27 Nov 2012, 03:12 AM
  2. sub categories not showing when I click a category
    By UrKoS in forum Basic Configuration
    Replies: 6
    Last Post: 5 Sep 2011, 09:00 PM
  3. I want to disable capture/void with Authorize.net in ZenCart Admin Order Page in 1.39
    By nfallat in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 29 Jul 2010, 10:30 PM
  4. On Click Javascript > Categories?
    By dharma in forum General Questions
    Replies: 0
    Last Post: 12 Jan 2008, 08:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR