X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   help changing navigation tabs based on current page (https://forum.x-cart.com/showthread.php?t=10851)

zilker 12-09-2004 08:57 PM

help changing navigation tabs based on current page
 
Hello,

I need some help with my navigation tabs. They can be seen here:

http://toybuyandsell.com/store/customer/home.php

Basically, I want them to change based on what page the user is on. If they click the home page, the "home" tab will be selected. I was able to make this happen for the home, buy and help tabs by using the following if statements:

Code:

<table cellpadding=0 cellspacing=0 border=0>
<tr valign="bottom">
<td>{if $main eq "catalog" and $current_category.category eq ""}[img]{$ImagesDir}/tab_home_.gif[/img]{else}[img]{$ImagesDir}/tab_home.gif[/img]{/if}</td>

<td>{if $main eq "cart" or $main eq "wishlist" or $main eq "anonymous_checkout" or $main eq "checkout" or $main eq "product" or $main eq "giftcert" or $main eq "catalog"}[img]{$ImagesDir}/tab_buy_.gif[/img]{else}[img]{$ImagesDir}/tab_buy.gif[/img]{/if}</td>

<td>[img]{$ImagesDir}/tab_sell.gif[/img]</td>

<td>[img]{$ImagesDir}/tab_contact.gif[/img]</td>

<td>{if $main eq "help"}[img]{$ImagesDir}/tab_help_.gif[/img]{else}[img]{$ImagesDir}/tab_help.gif[/img]{/if}</td>
</tr>
</table>


A simple if statement will provide the results of a "main" section but I haven't found out how to make it happen for a section under main. Example...contactus is under help. I've tried the following but it doesn't work:

Code:

{if $section eq "contactus"}[img]{$ImagesDir}/tab_contact_.gif[/img]{else}[img]{$ImagesDir}/tab_contact.gif[/img]{/if}

Can anyone help? I think it's just a smarty command that I don't know of.

Jon 12-09-2004 11:39 PM

The section variable gets passed when the help.tpl is called through the common_templates.tpl so it won't be available globally. You can't then use it on your other templates.

You can try:

Code:

{$smarty.get.section}

zilker 12-10-2004 10:23 AM

Thanks for the reply. I took what you gave me and rearranged the if statements. Just incase anyone else wants to use this idea, here's the code.

Code:

<table cellpadding=0 cellspacing=0 border=0 align="right">
<tr valign="bottom">

<td>
{if $main eq "catalog" and $location eq ""}
[img]{$ImagesDir}/tab_home_.gif[/img]

{else}
<a href="home.php">
[img]{$ImagesDir}/tab_home.gif[/img]</a>{/if}
</td>

<td>
{if $main eq "cart" or $main eq "wishlist" or $main eq "anonymous_checkout" or $main eq "checkout" or $main eq "product" or $main eq "giftcert"}
[img]{$ImagesDir}/tab_buy_.gif[/img]

{elseif $main eq "catalog" and $location ne ""}
[img]{$ImagesDir}/tab_buy_.gif[/img]

{elseif $smarty.get.section eq "buy"}
[img]{$ImagesDir}/tab_buy_.gif[/img]

{else}
[img]{$ImagesDir}/tab_buy.gif[/img]
{/if}
</td>

<td>
{if $smarty.get.section eq "sell"}[img]{$ImagesDir}/tab_sell_.gif[/img]

{else}
<a href="help.php?section=contact_us">
[img]{$ImagesDir}/tab_contact.gif[/img]</a>
{/if}
</td>

<td>
{if $smarty.get.section eq "contact_us"}
[img]{$ImagesDir}/tab_contact_.gif[/img]

{else}
[img]{$ImagesDir}/tab_contact.gif[/img]
{/if}</td>

<td>
{if $smarty.get.section eq "Password_Recovery"}
[img]{$ImagesDir}/tab_help_.gif[/img]

{elseif $smarty.get.section eq "Password_Recovery_message"}
[img]{$ImagesDir}/tab_help_.gif[/img]

{elseif $smarty.get.section eq "Password_Recovery_error"}
[img]{$ImagesDir}/tab_help_.gif[/img]

{elseif $smarty.get.section eq "FAQ"}
[img]{$ImagesDir}/tab_help_.gif[/img]

{elseif $smarty.get.section eq "about"}
[img]{$ImagesDir}/tab_help_.gif[/img]

{elseif $smarty.get.section eq "business"}
[img]{$ImagesDir}/tab_help_.gif[/img]

{elseif $smarty.get.section eq "conditions"}
[img]{$ImagesDir}/tab_help_.gif[/img]

{elseif $smarty.get.section eq "publicity"}
[img]{$ImagesDir}/tab_help_.gif[/img]

{else}[img]{$ImagesDir}/tab_help.gif[/img]

{/if}</td>
</tr>
</table>


Works great!!

ghhoz 01-10-2005 10:42 PM

Thanks for sharing this code, it was looking for this same thing. Just one questions, what file do you edit for this code?

Thanks again and BTW your site you are developing looks great.

zilker 01-11-2005 07:56 AM

I inserted that into the head.tpl file although it can be placed in any file. Let me know if I can do anything else to help you.


All times are GMT -8. The time now is 11:53 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.