Removing Main navigation bar except on Main page
Hey guys,
I am customizing a new site and I would like the custom nav bar "the main category bar" that is usually left side to only show on the index page of the site.
Can this be done through admin? Or do I just have make this part of the index page with html?
Thanks in advance!
Red
Re: Removing Main navigation bar except on Main page
There won't be an admin setting for this, but it will be a simple modification to (I think) /includes/templates/your_template/templates/tpl_categories.php. I would have to check on that to make sure.
By "index page", do you mean the home page only? All of the pages that show categories are "index" pages, in Zen Cart's terminology, so it can be confusing.
For home page use, wrap the following code around whatever you want to control:
PHP Code:
if ($this_is_home_page) { //execute only on home page
... [ code ] ...
} //execute only on home page
-------
There is an even simpler way to do this, using CSS. First, you will need to correct a typo in /includes/templates/template_default/common/tpl_main_page.php (and in your custom copy if you have one). Around line 41,
PHP Code:
$body_id = ($this_is_main_page) ? 'indexHome' : str_replace('_', '', $_GET['main_page']);
change the "main" to "home":
PHP Code:
$body_id = ($this_is_home_page) ? 'indexHome' : str_replace('_', '', $_GET['main_page']);
This may have been corrected in the source since I downloaded my test copy nine months ago; I am sure it is correct in the currently available version 1.3.7.1.
So, that taken care of, add to your stylesheet
Code:
#categories {display: none;}
#indexHome #categories {display: block;}
and the categories sidebox will display only on the home page.
Re: Removing Main navigation bar except on Main page
Thank you for your response!!! Yes I meant the home page sorry it took me so long. I t has taken a while for my client to get together her things and we are now back working on it.
We will give this a shot trying the CSS file first!
Renee
Re: Removing Main navigation bar except on Main page
Quote:
Originally Posted by
gjh42
add to your stylesheet
Code:
#categories {display: none;}
#indexHome #categories {display: block;}
and the categories sidebox will display only on the home page.
Glenn - just wanted to say this is an awesome solution.
I have been trying to figure out how to get sideboxes to only appear on certain pages and this is a great way to do it without messing around with the PHP code.
It is very easy to implement for any sidebox and any page, thanks to all the default ID tags built into Zen Cart.
Lisa
Re: Removing Main navigation bar except on Main page
You do need to be aware that this method still goes through the process of running the code for the sideboxes even though they are not displayed. This *might* add measurably to the page loading time, depending on circumstances. If you find speed issues, you should go to selectively disabling sideboxes in the PHP files.