Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Add a Tab to the top of your menu! Rate Topic   - - - - -

 

Posted 22 May 2008 - 05:00 AM #1

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}
            <div class="top-menu{$but_active}-left-bg">
                <div class="top-menu{$but_active}-right-bg">
                    [COLOR=Red]<div class="top-menu{$but_active}-bg" onclick="fn_redirect('{$index_script}?{$target_name}=[/COLOR][COLOR=Red][COLOR=Blue]knowledgebase[/COLOR]');">
                        <a href="{$index_script}?{$target_name}=[/COLOR][COLOR=Red][COLOR=Blue]knowledgebase[/COLOR]" class="top-menu-title">{[/COLOR][COLOR=Red][COLOR=Blue]$lang.knowledgebase[/COLOR]}</a>[/COLOR]
                    </div>
                </div>
            </div>[/COLOR]
ORANGE = ENTIRE TAB
RED = INTERNAL CODING ELEMENTS OF THE TAB
BLUE = TARGETS RELATIVE TO THE TAB

*Warning*
"ENSURE YOU HAVE A BACKUP"

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

<div class="wrapper-top-menu-left">
<div class="wrapper-top-menu-right">
<div class="wrapper-top-menu">

    <div class="logo-image-wrapper">
        <a href="{$index_script}"><img src="{$images_dir}/{$manifest.Customer_logo.filename}" width="{$manifest.Customer_logo.width}" height="{$manifest.Customer_logo.height}" border="0" alt="{$settings.Company.company_name}" /></a>
    </div>
    <div class="top-menu-tabs-wrapper">
        <div class="float-right">
            {include file="top_quick_links.tpl"}
        </div>
        <div class="top-menu-tabs">

            {if $target == 'checkout' || $mode == 'cart'}
                {assign var='but_active' value='-active'}
            {else}
                {assign var='but_active' value=''}
            {/if}
            <div class="top-menu{$but_active}-left-bg">
                <div class="top-menu{$but_active}-right-bg">
                    <div class="top-menu{$but_active}-bg" onclick="fn_redirect('{$index_script}?{$target_name}=checkout&{$mode_name}=cart')">
                        <a href="{$index_script}?{$target_name}=checkout&{$mode_name}=cart" class="top-menu-title">{$lang.view_cart}</a>
                    </div>
                </div>
            </div>
            
            {if $target == 'knowledgebase'}
                {assign var='but_active' value='-active'}
            {else}
                {assign var='but_active' value=''}
            {/if}
            <div class="top-menu{$but_active}-left-bg">
                <div class="top-menu{$but_active}-right-bg">
                    <div class="top-menu{$but_active}-bg" onclick="fn_redirect('{$index_script}?{$target_name}=knowledgebase');">
                        <a href="{$index_script}?{$target_name}=knowledgebase" class="top-menu-title">{$lang.knowledgebase}</a>
                    </div>
                </div>
            </div>

            {if $target == 'profiles' || $target == 'auth'}
                {assign var='but_active' value='-active'}
            {else}
                {assign var='but_active' value=''}
            {/if}
            {if $auth.user_id}
            <div class="top-menu{$but_active}-left-bg">
                <div class="top-menu{$but_active}-right-bg">
                    <div class="top-menu{$but_active}-bg" onclick="fn_redirect('{$index_script}?{$target_name}=profiles&{$mode_name}=update');">
                        <a href="{$index_script}?{$target_name}=profiles&{$mode_name}=update" class="top-menu-title">{$lang.my_account}</a>
                    </div>
                </div>
            </div>
            {else}
            <div class="top-menu{$but_active}-left-bg">
                <div class="top-menu{$but_active}-right-bg">
                    <div class="top-menu{$but_active}-bg" onclick="fn_redirect('{$index_script}?{$target_name}=auth&{$mode_name}=login_form');">
                        <a href="{$index_script}?{$target_name}=auth&{$mode_name}=login_form" class="top-menu-title">{$lang.my_account}</a>
                    </div>
                </div>
            </div>
            {/if}

            {if $mode == 'catalog' || $target == 'products' || $target == 'categories' || $target == 'manufacturers'}
                {assign var='but_active' value='-active'}
            {else}
                {assign var='but_active' value=''}
            {/if}
            <div class="top-menu{$but_active}-left-bg">
                <div class="top-menu{$but_active}-right-bg">
                    <div class="top-menu{$but_active}-bg" onclick="fn_redirect('{$index_script}?{$mode_name}=catalog');">
                        <a href="{$index_script}?{$mode_name}=catalog" class="top-menu-title">{$lang.catalog}</a>
                    </div>
                </div>
            </div>
            
            {if $target == '' && $mode == ''}
                {assign var='but_active' value='-active'}
            {else}
                {assign var='but_active' value=''}
            {/if}
            <div class="top-menu{$but_active}-left-bg">
                <div class="top-menu{$but_active}-right-bg">
                    <div class="top-menu{$but_active}-bg" onclick="fn_redirect('{$index_script}');">
                        <a href="{$index_script}" class="top-menu-title">{$lang.home}</a>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
</div>
</div>

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
(can't recall explicitly which ones work)
I've moved on from CS-Cart to WooC******** - If you need anything I can be of little help.

 
  • mdekok3000
  • Senior Member
  • Members
  • Join Date: 06-Feb 08
  • 883 posts

Posted 22 May 2008 - 05:58 AM #2

Your 1.3.5 SP3 top_menu.tpl file looks nothing like my 1.3.5 SP3 top_menu.tpl file.
[SIZE=2]
[/SIZE]

 
  • zardos
  • Senior Member
  • Members
  • Join Date: 08-Feb 06
  • 1062 posts

Posted 22 May 2008 - 01:03 PM #3

He could be using a different skin.

 

Posted 02 June 2008 - 04:37 PM #4

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
1.3.5 about to make the switch...
Free Shipping + Real Time Shipping Mod

 
  • rcaubin
  • Junior Member
  • Members
  • Join Date: 11-Jul 08
  • 10 posts

Posted 14 July 2008 - 05:02 AM #5

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

<div class="top-menu{$but_active}-left-bg">
    <div class="top-menu{$but_active}-right-bg">
        <div class="top-menu{$but_active}-bg" onclick="fn_redirect('{$index_script}?{$target}={$target}&{$mode_name}={$mode')">
            <a href="{$index_script}?{$target_name}={$target}&{$mode_name}={$mode}" class="top-menu-title">{$title}</a>
        </div>
    </div>
</div>

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

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

<div class="wrapper-top-menu-left">
<div class="wrapper-top-menu-right">
<div class="wrapper-top-menu">
	<div class="logo-image-wrapper">
		<a href="{$index_script}"><img src="{$images_dir}/{$manifest.Customer_logo.filename}" width="{$manifest.Customer_logo.width}" height="{$manifest.Customer_logo.height}" border="0" alt="{$settings.Company.company_name}" /></a>
	</div>
	<div class="top-menu-tabs-wrapper">
		<div class="float-right">
			{include file="top_quick_links.tpl"}
		</div>
		<div class="top-menu-tabs">
			{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}            
		</div>
	</div>
</div>
</div>
</div>

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)

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 28 July 2008 - 12:19 AM #6

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.

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 28 July 2008 - 12:26 AM #7

So based on the code below:

{if $target == 'knowledgebase'}
                {assign var='but_active' value='-active'}
            {else}
                {assign var='but_active' value=''}
            {/if}
            <div class="top-menu{$but_active}-left-bg">
                <div class="top-menu{$but_active}-right-bg">
                    <div class="top-menu{$but_active}-bg" onclick="fn_redirect('{$index_script}?{$target_name}=knowledgebase');">
                        <a href="{$index_script}?{$target_name}=knowledgebase" class="top-menu-title">{$lang.knowledgebase}</a>
                    </div>
                </div>
            </div>

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

 

Posted 28 July 2008 - 12:47 AM #8

I can't guarantee it however that should work, not 100% sure but I think there needs to be an
&
somewhere in that link
I've moved on from CS-Cart to WooC******** - If you need anything I can be of little help.

 
  • whiplash13
  • PM Extraordinaire
  • Members
  • Join Date: 01-Feb 08
  • 704 posts

Posted 28 July 2008 - 01:03 AM #9

Just figured it out:

To test the condition:
{if $target == 'pages' && $page.page_id == 'support'}

and

For the fn_redirect url on click:

<a href="{$index_script}?{$target_name}=pages&page_id=support" class="top-menu-title">Support</a>