![]() |
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 |
Re: Making Navbar Unique on Each Page
which pages do you have in teh nav bar?
|
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.)
|
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 |
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 |
Re: Making Navbar Unique on Each Page
It worked perfectly Ashley, Thank-you SO much!
|
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! |
Re: Making Navbar Unique on Each Page
try $main eq "cart"
|
Re: Making Navbar Unique on Each Page
the page_data variable is only for static pages.
|
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!
|
All times are GMT -8. The time now is 02:19 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.