Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Limit categories displayed in header??

Limit categories displayed in header??

Locked

Views: 1,212

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
13 Sep 2008, 9:44 PM
#1
nyssa avatar

nyssa

New Zenner

Join Date:
Sep 2008
Posts:
7
Plugin Contributions:
0

Limit categories displayed in header??

As I add categories I do not want them *all *displayed at the base of the header: I would like to keep the header clean with just two or three chosen categories displaying (I don't want to turn off the whole display in admin), and provide the extensive listing in the sidebox only. Can I do this? Where is the code which inserts categories into the header?? :blush:

13 Sep 2008, 10:08 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Limit categories displayed in header??

The easiest thing for you may be to turn off the cat-tabs bar and add the categories you want as internal ez-page links, and use the ez-pages header nav.
Can you give a link to your site so we can see what you have?

13 Sep 2008, 11:16 PM
#3
nyssa avatar

nyssa

New Zenner

Join Date:
Sep 2008
Posts:
7
Plugin Contributions:
0

Re: Limit categories displayed in header??

I see where you're going with this, and sort-of like it as a workaround solution. I also greatly appreciate the input!! Still wish I knew where the code lives which places the categories in the header though, even if only for my own edification. Here's my site if you're curious: I'm obviously still not comfortable with EZ-Pages, but could easily place other code to do the job as you suggest. Thanks again!

14 Sep 2008, 12:22 AM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Limit categories displayed in header??

/includes/modules/your_template/categories_tabs.php would be the place to edit the cat-tabs.
You could add a test inside the while loop to skip the contents unless the cat being processed matched one of the ones you want to display.```php
while (!$categories_tab->EOF) {

// currently selected category
if ((int)$cPath == $categories_tab->fields['categories_id']) {
$new_style = 'category-top';
$categories_tab_current = '<span class="category-subs-selected">' . $categories_tab->fields['categories_name'] . '</span>';
} else {
$new_style = 'category-top';
$categories_tab_current = $categories_tab->fields['categories_name'];
}

// create link to top level category
$links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . (int)$categories_tab->fields['categories_id']) . '">' . $categories_tab_current . '</a> ';
$categories_tab->MoveNext();
}

14 Sep 2008, 12:45 AM
#5
nyssa avatar

nyssa

New Zenner

Join Date:
Sep 2008
Posts:
7
Plugin Contributions:
0

Re: Limit categories displayed in header??

Thanks Glenn - exactly what I was looking to do ... for hours before giving up! You don't know how much I appreciate all your help on this forum: why I love my zen-cart is you all helpful followers. All I can do is html and css - but this is the first time I couldn't pull through my php lameness without making a post. :clap:

14 Sep 2008, 2:35 AM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Limit categories displayed in header??

I didn't want to be redundant if you already knew what to do, but try this:```php
while (!$categories_tab->EOF) {

if (($categories_tab->fields['categories_id'] == 23) or ($categories_tab->fields['categories_id'] == 37)) { //process output for these categories only
// currently selected category
if ((int)$cPath == $categories_tab->fields['categories_id']) {
$new_style = 'category-top';
$categories_tab_current = '<span class="category-subs-selected">' . $categories_tab->fields['categories_name'] . '</span>';
} else {
$new_style = 'category-top';
$categories_tab_current = $categories_tab->fields['categories_name'];
}

// create link to top level category
$links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . (int)$categories_tab->fields['categories_id']) . '">' . $categories_tab_current . '</a> ';

} //process
$categories_tab->MoveNext();
}

17 Sep 2008, 3:40 AM
#7
nyssa avatar

nyssa

New Zenner

Join Date:
Sep 2008
Posts:
7
Plugin Contributions:
0

Re: Limit categories displayed in header??

ok ... well I tried that code in categories_tabs, but all the categories went away, as would be done in admin. I then tried every combination and permutation I could think of, along similar lines, and got one of two results: either the categories all went away, or code-confusion reigned and after a very-slow-load the entire page after the header went light blue sans information. I now suspect that fields are defined elsewhere - or differently - and that calling them out here results in mayhem. Ideas???