Add a Tab to the top of your menu!

VERSIONS: 1.3.5sp3 (May work with older versions)

SKINS: Basic (May work with other skins)



Remember to add the $lang.variable
by adding the “Add new item” section of the language section

(/admin.php?target=languages)

Simply Copy + Paste the passage below to add the Knowledge base tab.

Add the code where-ever it is required between tabs



/skins/basic/customer/top_menu.tpl


[COLOR=DarkOrange] {if $target == '[COLOR=Blue]knowledgebase[/COLOR]'}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}

[/COLOR][COLOR=DarkOrange]ORANGE = ENTIRE TAB

[COLOR=Red]RED = INTERNAL CODING ELEMENTS OF THE TAB[/COLOR]

[COLOR=Blue]BLUE = TARGETS RELATIVE TO THE TAB[/COLOR]

[/COLOR]

Warning

“ENSURE YOU HAVE A BACKUP”



```php {* $Id: top_menu.tpl 3838 2007-09-05 07:49:51Z zeke $ *}







{$settings.Company.company_name}



{include file="top_quick_links.tpl"}



{if $target == 'checkout' || $mode == 'cart'}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}


{if $target == 'knowledgebase'}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}


{if $target == 'profiles' || $target == 'auth'}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}
{if $auth.user_id}

{else}

{/if}

{if $mode == 'catalog' || $target == 'products' || $target == 'categories' || $target == 'manufacturers'}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}


{if $target == '' && $mode == ''}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}








```You can add more variables such as page_id and topic_id which can be used to directly link FAQ pages, Shipping policies etc.

Those who use the $page_id variables please post the urls for others
[SIZE=1](can't recall explicitly which ones work)[/SIZE]

Your 1.3.5 SP3 top_menu.tpl file looks nothing like my 1.3.5 SP3 top_menu.tpl file.

He could be using a different skin.

Jesse,



Thanks for this… I’ve been looking for something like this. Here’s my question… we added an item for “Reviews”… and linked it to a non cart page. It works fine if you click the text, but if you miss the text and click the button itself, then it trys to append the reviews url to the end of the cart url… not pretty. Any idea what I could tweak to make that work?



Thanks again,

JB

The first block of code was taken out of customer/top_menu.tpl and inserted into buttons/top_menu_tab.tpl with a few new $variables: $title, $target, $mode



Then adding a new tab to the top menu is as easy as adding this in top_menu.tpl

{include file=“top_menu_tab.tpl” title=$lang.variable target=value mode=value}



I come from an object oriented programing background, and it just seemed logical to take the tab button completely out of the tab strip and make it its own entity.



The only real requirement is the title value. If no target and mode are supplied, the home page is returned.



If someone could rewrite the code that appears in top_menu_tab.tpl to properly construct the link url to only append the target and/or mode parameters if they are included, currently if they are left out, the url will look like: index.php?target=&mode= which is kind of ugly.



Create the following file: /customer/buttons/top_menu_tab.tpl


```php




```

And here's how I use it within customer/top_menu.tpl

```php
{* $Id: top_menu.tpl 3838 2007-09-05 07:49:51Z zeke $ *}





{$settings.Company.company_name}



{include file="top_quick_links.tpl"}


{if $target == 'checkout' || $mode == 'cart'}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}
{include file="buttons/top_menu_tab.tpl" title=$lang.view_cart target="checkout" mode="cart"}

{if $target == 'profiles' || $target == 'auth'}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}

{if $auth.user_id}
{include file="buttons/top_menu_tab.tpl" title=$lang.my_account target="profiles" mode="update"}
{else}
{include file="buttons/top_menu_tab.tpl" title=$lang.my_account target="auth" mode="login_form"}
{/if}

{if $mode == 'catalog' || $target == 'products' || $target == 'categories' || $target == 'manufacturers'}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}
{include file="buttons/top_menu_tab.tpl" title=$lang.catalog mode="catalog"}

{if $target == '' && $mode == ''}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}
{include file="buttons/top_menu_tab.tpl" title=$lang.home}





```

and here's the output from the smarty template debugger showing that there four tabs being included:

top.tpl (0.00662)
top_menu.tpl (0.00372)
top_quick_links.tpl (0.00195)
addons/promotions/top_quick_links.tpl (0.00036)
top_menu_tab.tpl (0.00023)
top_menu_tab.tpl (0.00021)
top_menu_tab.tpl (0.00021)
top_menu_tab.tpl (0.00021)

Great contribution with lots of uses. Needed to mod it quite a bit to get it to work with New Vision Blue but worked great after a few minutes of work.

So based on the code below:


{if $target == 'knowledgebase'}
{assign var='but_active' value='-active'}
{else}
{assign var='but_active' value=''}
{/if}





If I wanted a tab it to point to a page, say Support, and not the knowledgebase. Should $target == ‘pages’ && $page_id ==‘support’ work?

I can’t guarantee it however that should work, not 100% sure but I think there needs to be an & somewhere in that link

Just figured it out:



To test the condition:

{if $target == ‘pages’ && $page.page_id == ‘support’}



and



For the fn_redirect url on click:



Support