Re: Twitch Hide Any Category
Note: since tpl_categories.php has not changed in a long time, this will work on any version from before v1.3.7 to v1.5.0.
Your example is customized to run on a betterCategories tpl_categories.php file, which is quite different in this area from a stock file.
Quote:
$content .= '';
//this line clears the line data so it will NOT be inserted into the sidebox
.= '' does not clear anything; for that you would want = ''.
Re: Twitch Hide Any Category
Quote:
Originally Posted by
gjh42
Note: since tpl_categories.php has not changed in a long time, this will work on any version from before v1.3.7 to v1.5.0.
Your example is customized to run on a betterCategories tpl_categories.php file, which is quite different in this area from a stock file.
.= '' does not clear anything; for that you would want = ''.
Failing to include the period before the equal sign will break the sidebox code. It is necessary in this version of the file.
I will upload the stock code for ZenCart 1.50 after testing later today.
Twitch.
Re: Twitch Hide Any Category
If $content already holds prior item output, then you would obviously not want to clear it; but .= '' will do absolutely nothing and I don't see the point of including it.
Anyway, this concept is a good option to make available for people. Thanks for presenting it.
Re: Twitch Hide Any Category
Looking closer at your code, you have a series of new nested if() { }else{ }statements. This is an inefficient method which could be streamlined by simply using one
if() {
}elseif(){
}elseif(){
}else{
}
statement, which would not require keeping track of numbers of nested } at the bottom. Only one new } would be needed.
Better yet would be to put the list of excluded cPaths in one place, requiring nothing more than adding a number to include a new cPath in the list. Something like this
PHP Code:
if (in_array(str_replace('cPath=','',$box_categories_array[$i] ['path']), explode(',', '3_10,3_7,5_23,9')) {
//do nothing
}else{
//the standard code
}
Re: Twitch Hide Any Category
So Glen what is the proper way to implement this in Zen 1.5.1?
I have created the Gift Certificate under it's own category, and I do not want it to show it in the left box. I would manually add the path to the product Category where I want it to appear on the site pages.
Is there a better more proper way to achieve this.
Re: Twitch Hide Any Category
Using the stock tpl_categories.php as a base:
PHP Code:
if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
// skip if this is for the document box (==3)
} else {
$content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
add this to the if() test
PHP Code:
or (in_array(str_replace('cPath=','',$box_categories_array[$i] ['path']), explode(',', '3_10,3_7,5_23,9'))/*hidden categories*/
to get
PHP Code:
if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1) or (in_array(str_replace('cPath=','',$box_categories_array[$i] ['path']), explode(',', '3_10,3_7,5_23,9'))/*hidden categories*/) {
// skip if this is for the document box (==3)
} else {
$content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
This is all you need to do to hide categories 3_10, 3_7, 5_23 and 9 in the categories sidebox. Adjust the list as desired. You may also want to hide it in other places, which would be another job entirely..
Re: Twitch Hide Any Category
Re: Twitch Hide Any Category
I just tried this code modification using 'Categories Dressing' tpl_categories. I still can't hide my categories.
Re: Twitch Hide Any Category
What exactly did you do to try to hide your category? Post your version (in php tags) so we can troubleshoot.