Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 45
  1. #11
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    That code should work...I will test today...I am thinking the first case show the products, the second case hide the products...I will try to remember to update...

  2. #12
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    Upon testing per se I discovered the code you suggest has no effect.

    The test must be done on the product links themselves not on the categories links like you suggested.

    In other words if the product's categoryID = cPath or some similar test then display

    $content .= '<span class="'. $div_class .'">'.
    $indent.$separator.'<a class="'. $a_class .'" href="'. $link .'">'. $box_categories_array[$i]['name'] .'</a>'. $count .
    '</span><br />';

    otherwise don't display it...

    Can I use the same test as in the other code??

    <air code>
    $div_class = '';
    If product's category ID != cPath of the current category page then
    $div_class = 'hide-this-product';
    $content .= '<span class="'. $div_class .'">'.
    $indent.$separator.'<a class="'. $a_class .'" href="'. $link .'">'. $box_categories_array[$i]['name'] .'</a>'. $count .
    '</span><br />';
    end If
    </air code>

    Thank you, Tom

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

    Default Re: How to make clicking a category display all its items under the category name??

    I suspected that the category id might not be directly available for products:
    If $box_categories_array[$i]['category_id'] is not populated for a product, you will need an alternate test like
    (zen_get_products_category_id($products_id) == $cPath)
    so try this:
    PHP Code:
         $div_class='';
         if (
    $products_id){
             if ((
    $products_id)&&(($box_categories_array[$i]['products_id']==$products_id) or (zen_get_products_category_id($products_id) == $cPath))){
                 
    $div_class='category-subs-selected';
             }
         }else{
             if((
    $current_category_id!=0)&&($box_categories_array[$i]['category_id']==$current_category_id)){
                 
    $div_class='category-subs-selected';
             }
         } 
    Check paren balance...
    Last edited by gjh42; 6 Feb 2013 at 08:55 PM.

  4. #14
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    Additional note: I'm not using any of the css classes in the code, I don't need them, I *do* need that span class to be hidden-desktop or visible-desktop depending on whether the product's cPath matches the current page.

    Thank you, Tom

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

    Default Re: How to make clicking a category display all its items under the category name??

    You do need the CSS classes... to hide the unwanted links. Styling to display: none; allows you to modify the behavior at any time if you want to, whereas hard-coding to delete the non-active items can only be changed by re-editing the PHP file.

  6. #16
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    help question Re: How to make clicking a category display all its items under the category name??

    Basically what's happening is this:

    Whatever code produces this HTML:

    <span class="">
    &nbsp;&nbsp;|_&nbsp;
    <a class="category-products" href="http://localhost/index.php?main_page=product_info&amp;cPath=&amp;products_id=1">
    Adjustable Rowing Rig (ARR)
    </a>
    </span>

    is NOT getting the $div_class -- nothing is being put in there...

    I'll try your suggestion though what would really work properly is for the above span to get a class put into it, the php code says it's supposed to get $div_class and it never does.

    Thank you, Tom

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

    Default Re: How to make clicking a category display all its items under the category name??

    Do you have my code in post #8 implemented, with $div_class?

    ...'<a class="'. $a_class . ' ' . $div_class .'" href="'...


    If so, some debug lines are in order, to output relevant values directly so we can see what they are and adjust tests accordingly.

  8. #18
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    Quote Originally Posted by tlyczko View Post
    Additional note: I'm not using any of the css classes in the code, I don't need them, I *do* need that span class to be hidden-desktop or visible-desktop depending on whether the product's cPath matches the current page.

    Thank you, Tom
    hidden-desktop does set display: none but $div_class is not being applied to the PRODUCTS!!

    I need $div_class to be applied to the PRODUCTS not the categories, I don't care about the categories. :)

    Thank you, Tom

  9. #19
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    Quote Originally Posted by gjh42 View Post
    Do you have my code in post #8 implemented, with $div_class?

    ...'<a class="'. $a_class . ' ' . $div_class .'" href="'...


    If so, some debug lines are in order, to output relevant values directly so we can see what they are and adjust tests accordingly.
    I've done this...but the SPAN is what must get a class for the products to be selectively hidden depending on if the product ID and cPath match up...the empty SPAN is never getting a class with the code you suggested...I made all the proper changes you suggested.

    Code:
          // 2/6/13 new code to show/hide products
          $div_class='';
          if ($products_id){
              if (($products_id)&&(($box_categories_array[$i]['products_id']==$products_id) or ($box_categories_array[$i]['category_id']==$cPath))){
                  $div_class='category-subs-selected';
              }
          }else{
              if(($current_category_id!=0)&&($box_categories_array[$i]['category_id']==$current_category_id)){
                  $div_class='category-subs-selected';
              }
          }


    Code:
    <div id="categorylistboxContent" class="sideBoxContent">
    
    <span class="category-subs-selected">
    <a class="category-top category-subs-selected" href="http://localhost/index.php?main_page=index&amp;cPath=1">Canoe Accessories</a></span><br>
    
    <span class="">&nbsp;&nbsp;|_&nbsp;<a class="category-products " href="http://localhost/index.php?main_page=product_info&amp;cPath=&amp;products_id=1">Adjustable Rowing Rig (ARR)</a></span><br>
    
    <span class="">&nbsp;&nbsp;|_&nbsp;<a class="category-products " href="http://localhost/index.php?main_page=product_info&amp;cPath=&amp;products_id=3">Aluminum Clamps (CL)</a></span><br>
    
    <span class="">&nbsp;&nbsp;|_&nbsp;<a class="category-products " href="http://localhost/index.php?main_page=product_info&amp;cPath=&amp;products_id=2">Ash Motor Mount (AMM)</a></span><br>
    
    <span class="">&nbsp;&nbsp;|_&nbsp;<a class="category-products " href="http://localhost/index.php?main_page=product_info&amp;cPath=&amp;products_id=4">Canvas &amp; Ash Folding Camp Stool (CAST)</a></span><br>
    
    <span class=""><a class="category-top " href="http://localhost/index.php?main_page=index&amp;cPath=2">Canoe Backrests</a></span><br>
    
    <span class="">&nbsp;&nbsp;|_&nbsp;<a class="category-products " href="http://localhost/index.php?main_page=product_info&amp;cPath=&amp;products_id=5">test</a></span><br>
    
    <span class=""><a class="category-top " href="http://localhost/index.php?main_page=index&amp;cPath=4">Canoe Yokes &amp; Thwarts</a></span><br>
    
    <span class=""><a class="category-top " href="http://localhost/index.php?main_page=index&amp;cPath=3">Specialty Canoe Seats</a></span><br></div>	
    
    </ul>
    </div>

    I hope this makes things clearer...I've been trying to figure out how to make the EMPTY SPAN get a class...


    Code:
    	//add content
    	$content .= '<span class="'. $div_class .'">'. 
         $indent.$separator.'<a class="'. $a_class . ' ' . $div_class .'" href="'. $link .'">'. $box_categories_array[$i]['name'] .'</a>'. $count .
    	'</span><br />';


    Thank you, Tom

  10. #20
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: How to make clicking a category display all its items under the category name??

    I put in this debug code: echo ' products_cat=' . $box_categories_array[$i]['category_id'];
    nothing appears for the value regardless where the debug code is place

    and the spans never get the $div_class value, I can't figure out why...

    Thank you, Tom

 

 
Page 2 of 5 FirstFirst 1234 ... LastLast

Similar Threads

  1. v151 How to display the last category name
    By Kevin205 in forum General Questions
    Replies: 6
    Last Post: 30 Oct 2013, 04:11 AM
  2. How to link the category name under featured products
    By newbie456 in forum General Questions
    Replies: 0
    Last Post: 8 Sep 2011, 09:38 AM
  3. Replies: 3
    Last Post: 12 Jun 2011, 06:26 AM
  4. how to add the optiona name(text type) to all products under a category?
    By mybiz9999 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 7 Aug 2010, 04:24 AM
  5. Displaying category name under new items thumbnails
    By aeolidia in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 20 Dec 2006, 12:05 AM

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