Forums / Templates, Stylesheets, Page Layout / is on-state look available for navigation?

is on-state look available for navigation?

Locked

Views: 1,152

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
9 Feb 2010, 12:39 AM
#1
whiteboxer avatar

whiteboxer

New Zenner

Join Date:
Apr 2006
Location:
Columbus, OH
Posts:
97
Plugin Contributions:
0

is on-state look available for navigation?

Is there a way in zen-cart to set up an on-state look for the navigation?

9 Feb 2010, 2:37 AM
#2
gjh42 avatar

gjh42

Black Belt

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

Re: is on-state look available for navigation?

Not built in, but anything can be coded. A test for $current_page_base == 'whatever' would give you the basis for setting a "currentPage" class, which could be styled in the stylesheet.

The categories sidebox already has the classes for this available and ready to be styled. The Classic template uses these classes.

9 Feb 2010, 6:05 PM
#3
whiteboxer avatar

whiteboxer

New Zenner

Join Date:
Apr 2006
Location:
Columbus, OH
Posts:
97
Plugin Contributions:
0

Re: is on-state look available for navigation?

I'm a real novice at PHP. So say I wanted to apply an additional class to a navigation list item using this method, how would I alter the code? Currently, I have the navigation in its own component (navigation.php) and inserting in on the main page template. Here's the basic structure for the nav items:

<ul id="mainnav"> <li id="nav_home"><a href="[link to home page]">Home</a></li> [other nav list here] </ul>

I'm thinking the best way is to use the $current_page_base to add a class to the list item so that it looks like this:

<li id="nav_home" class="currentpage"><a href="[link to home page]">Home</a></li>

PHP-wise, how would I code that?

9 Feb 2010, 6:33 PM
#4
gjh42 avatar

gjh42

Black Belt

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

Re: is on-state look available for navigation?

If you're going to add code to highlight the current page link, you might as well make it not a link to itself at the same time. It's a good practice to avoid links that lead to exactly where you are - they serve no purpose.

<?php if($this_is_home_page){ ?>
<li id="nav_home" class="currentpage">Home</li>
<?php }else{ ?>
<li id="nav_home" class="notcurrentpage"><a href="[link to home page]">Home</a></li>
<?php } ?>

<?php if($current_page_base == 'contact_us'){ ?>
<li id="nav_contact" class="currentpage">Contact Us</li>
<?php }else{ ?>
<li id="nav_contact" class="notcurrentpage"><a href="[link to contact page]">Contact Us</a></li>
<?php } ?>
```There are various other things you can test for different situations, like $_SESSION['customer_id'] to tell if the customer is logged in (so you can show the login or logout link as appropriate).
9 Feb 2010, 6:37 PM
#5
whiteboxer avatar

whiteboxer

New Zenner

Join Date:
Apr 2006
Location:
Columbus, OH
Posts:
97
Plugin Contributions:
0

Re: is on-state look available for navigation?

thanks. If I go that route (which seems like the best), how do I modify the links that go to ez-pages as well as product category pages? Here's the actual site to give you an idea what I mean:

http://www.thepresidentscroogereport.com/

9 Feb 2010, 7:16 PM
#6
gjh42 avatar

gjh42

Black Belt

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

Re: is on-state look available for navigation?

Looks like fun!
It would have been simpler to use the existing ez-page sidebox and footer menus, with ez-page internal links to lead to other pages, but now that you have it, you may as well keep it.

Ez-page detection can be done like this```php
if($current_page_base == 'page' and $_GET['id'] == 2){

// <li> for Interview

14 Feb 2010, 4:48 PM
#7
whiteboxer avatar

whiteboxer

New Zenner

Join Date:
Apr 2006
Location:
Columbus, OH
Posts:
97
Plugin Contributions:
0

Re: is on-state look available for navigation?

That worked. Any idea how i can get this to work for categories? I have two categories, books and music, that have navigation items where I want to use the same effect. I tried using the ez-page code, but not sure what to replace "page" with (or whatever I need to change on that line).

16 Feb 2010, 2:40 PM
#10
whiteboxer avatar

whiteboxer

New Zenner

Join Date:
Apr 2006
Location:
Columbus, OH
Posts:
97
Plugin Contributions:
0

Re: is on-state look available for navigation?

that sorta worked. One navigation item is going to a specific product in a category (cPath=1, ProductID=1). When you go to that product, the button isn't getting greyed out. Do I need to do something additonal to the code? I was hoping that just using the cPath would work. Here's the code below for that one and a link to the site:

<ul id="navigation"> <?php if($current_page_base == 'index' and $_GET['cPath'] == 1){ ?> <li id="nav_order" class="currentpage"><a href="http://www.thepresidentscroogereport.com/index.php?main_page=product_info&cPath=1&products_id=1"id="lastitem">Order</a></li> <?php }else{ ?> <li id="nav_order"><a href="http://www.thepresidentscroogereport.com/index.php?main_page=product_info&cPath=1&products_id=1"id="lastitem">Order</a></li> <?php } ?> </ul>

site URL: http://www.thepresidentscroogereport.com

16 Feb 2010, 4:23 PM
#11
gjh42 avatar

gjh42

Black Belt

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

Re: is on-state look available for navigation?

The specific product link would not use 'index' but 'product_info' page base, and $_GET['products_id'] == '1'.

href="http://www.thepresidentscroogereport.com/index.php?main_page=product_info&cPath=1&products_id=1"

16 Feb 2010, 4:58 PM
#12
whiteboxer avatar

whiteboxer

New Zenner

Join Date:
Apr 2006
Location:
Columbus, OH
Posts:
97
Plugin Contributions:
0

Re: is on-state look available for navigation?

that did it. Thanks a lot.