Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Making Navbar Unique on Each Page

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-19-2008, 01:39 PM
 
presson83 presson83 is offline
 

Senior Member
  
Join Date: Sep 2008
Posts: 143
 

Default Making Navbar Unique on Each Page

Hi All,

I'm wanting to add an active class to my navbar links. Obviously this class is only applied to the active page's li tag, so I need to be able to change my navbar depending on the page.

I currently have my nav code located in head.tpl which is called from customer/home.tpl. Since all the pages use customer/home.tpl (other than the shopping cart pages which use modules/fast lane checkout/home.tpl), I'm having trouble thinking of a way to make the navbar unique on each page. I'm sure there must be a way with smarty templates, I'm just not very versed in their usage.

Any help with adding an active class to a diff li element depending on the page would be MUCH appreciated!

-Nick
__________________
v 4.1.11, v 4.2
Reply With Quote
  #2  
Old 11-19-2008, 02:08 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Making Navbar Unique on Each Page

which pages do you have in teh nav bar?
__________________
xcart 5.1.2
Reply With Quote
  #3  
Old 11-19-2008, 02:42 PM
 
presson83 presson83 is offline
 

Senior Member
  
Join Date: Sep 2008
Posts: 143
 

Default Re: Making Navbar Unique on Each Page

My individual product pages, my contact page, and two static pages (also my shopping cart area, but that part I figured out because it uses a totally different template than the rest of my pages, so I made a unique head.tpl for that template which has the active class set properly for the shopping cart pages.)
__________________
v 4.1.11, v 4.2
Reply With Quote
  #4  
Old 11-19-2008, 03:54 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Making Navbar Unique on Each Page

you are going to use if and elseif statements

MAKE SURE YOU BACK UP FIRST!!!!!



{if $page_data.pageid eq 8}

Your content

{elseif $smarty.get.section eq "contactus"}

your content

{elseif $cat eq 381}

your content
{/if}

replace the 8 with your page ids
and 381 ith your cat id.

this is a start. you will have to play with this to get it right.

Ash
__________________
xcart 5.1.2
Reply With Quote
  #5  
Old 11-19-2008, 06:40 PM
 
presson83 presson83 is offline
 

Senior Member
  
Join Date: Sep 2008
Posts: 143
 

Default Re: Making Navbar Unique on Each Page

Awesome Ashley, thanks. I will play with some if else statements in my head.tpl file that includes my nav bar and see what I can come up with. Thank-you so much for your help!

-Nick
__________________
v 4.1.11, v 4.2
Reply With Quote
  #6  
Old 11-20-2008, 05:33 AM
 
presson83 presson83 is offline
 

Senior Member
  
Join Date: Sep 2008
Posts: 143
 

Default Re: Making Navbar Unique on Each Page

It worked perfectly Ashley, Thank-you SO much!
__________________
v 4.1.11, v 4.2
Reply With Quote
  #7  
Old 11-20-2008, 06:22 AM
 
presson83 presson83 is offline
 

Senior Member
  
Join Date: Sep 2008
Posts: 143
 

Default Re: Making Navbar Unique on Each Page

One last question - my active class works for when you have something in the shopping cart - because that's when it changes templates to the fast_lane_checkout template. When there's nothing in your cart however, the template is the same, therefore I need to write another elseif statement for the cart page. My attempts have been like this :

{elseif $page_data eq "cart"}
{elseif $page_data eq "shoppingcart"}
{elseif $page eq "cart"}
{elseif $page eq "shoppingcart"}

etc. etc. none of which have worked. I'm simply trying to get ahold of cart.php - any help is much appreciated!
__________________
v 4.1.11, v 4.2
Reply With Quote
  #8  
Old 11-20-2008, 06:34 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Making Navbar Unique on Each Page

try $main eq "cart"
__________________
xcart 5.1.2
Reply With Quote
  #9  
Old 11-20-2008, 06:35 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Making Navbar Unique on Each Page

the page_data variable is only for static pages.
__________________
xcart 5.1.2
Reply With Quote
  #10  
Old 11-20-2008, 07:12 AM
 
presson83 presson83 is offline
 

Senior Member
  
Join Date: Sep 2008
Posts: 143
 

Default Re: Making Navbar Unique on Each Page

Perfection! Thanks Ash. I knew I had seen the cart referred to like that..just couldn't remember that $main portion. Worked like a charm!
__________________
v 4.1.11, v 4.2
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:05 AM.

   

 
X-Cart forums © 2001-2020