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...
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...
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
I suspected that the category id might not be directly available for products:so try this: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)Check paren balance...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';
}
}
Last edited by gjh42; 6 Feb 2013 at 08:55 PM.
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
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.
Basically what's happening is this:
Whatever code produces this HTML:
<span class="">
|_
<a class="category-products" href="http://localhost/index.php?main_page=product_info&cPath=&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
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&cPath=1">Canoe Accessories</a></span><br> <span class=""> |_ <a class="category-products " href="http://localhost/index.php?main_page=product_info&cPath=&products_id=1">Adjustable Rowing Rig (ARR)</a></span><br> <span class=""> |_ <a class="category-products " href="http://localhost/index.php?main_page=product_info&cPath=&products_id=3">Aluminum Clamps (CL)</a></span><br> <span class=""> |_ <a class="category-products " href="http://localhost/index.php?main_page=product_info&cPath=&products_id=2">Ash Motor Mount (AMM)</a></span><br> <span class=""> |_ <a class="category-products " href="http://localhost/index.php?main_page=product_info&cPath=&products_id=4">Canvas & Ash Folding Camp Stool (CAST)</a></span><br> <span class=""><a class="category-top " href="http://localhost/index.php?main_page=index&cPath=2">Canoe Backrests</a></span><br> <span class=""> |_ <a class="category-products " href="http://localhost/index.php?main_page=product_info&cPath=&products_id=5">test</a></span><br> <span class=""><a class="category-top " href="http://localhost/index.php?main_page=index&cPath=4">Canoe Yokes & Thwarts</a></span><br> <span class=""><a class="category-top " href="http://localhost/index.php?main_page=index&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
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
Bookmarks