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)
-   -   Highlight current menu item (https://forum.x-cart.com/showthread.php?t=57709)

Wazowski 01-24-2011 01:46 PM

Highlight current menu item
 
Hello!

How do I make the menu to highlight the category where I▓m currently in (underline, bold)?

qualiteam 01-27-2011 04:14 AM

Re: Highlight current menu item
 
You should modify the "skin/common_files/customer/categories.tpl" template and add {if $c.categoryid eq $cat}style="font-style: bold;"{/if} condition into the category rendering loop.

cherie 01-27-2011 01:08 PM

Re: Highlight current menu item
 
You can also replace $cat with $current_category.categoryid if $cat happens to not be available on the page you are on. It may be a more consistent variable.

Wazowski 01-27-2011 06:40 PM

Re: Highlight current menu item
 
Quote:

Originally Posted by qualiteam
You should modify the "skin/common_files/customer/categories.tpl" template and add {if $c.categoryid eq $cat}style="font-style: bold;"{/if} condition into the category rendering loop.


Thank you Alex! But where is that 'category rendering loop'?

My code looks like that:

Code:


{if $categories_menu_list ne '' or $fancy_use_cache}
{capture name=menu}
{if $active_modules.Flyout_Menus}
  {include file="modules/Flyout_Menus/categories.tpl"}
  {assign var="additional_class" value="menu-fancy-categories-list"}
{else}
  <ul>
    {foreach from=$categories_menu_list item=c name=categories}
      <li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category|amp}</a></li>
    {/foreach}
  </ul>
  {assign var="additional_class" value="menu-categories-list"}
{/if}
{/capture}
{include file="customer/menu_dialog.tpl" title=$lng.lbl_categories content=$smarty.capture.menu}
{/if}


PhilJ 01-27-2011 07:35 PM

Re: Highlight current menu item
 
As Cherie says...
Code:


{foreach from=$categories_menu_list item=c name=categories}
<li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}"{if $current_category.categoryid eq $cat} style="font-style: bold;"{/if}>{$c.category|amp}</a></li>
{/foreach}


cherie 01-28-2011 02:29 PM

Re: Highlight current menu item
 
Close!
Code:

{if $current_category.categoryid eq $c.categoryid}
I think that's what you meant. :)

Wazowski 01-29-2011 12:08 AM

Re: Highlight current menu item
 
Went nuts with these templates!

1. The template path is not ⌠skin/common_files/customer/categories.tpl■ but ⌠skin/common_files/modules/Flyout_Menus/Icons/■ as far as I use Flyout Menus module.

2. I almost got mad trying to figure out why all changes were not displayed on the website. The answer was simple √ I had to clean cash with /cleanup.php.

3. Had to modify the code to

Code:


{if $current_category.categoryid eq $c.categoryid}
      <a href="home.php?cat={$catid}" style="text-decoration: underline">
{/if}



So now the whole <li> block looks like this:

Code:


  <li id="cat-layer-{$c.categoryid}"{interline name=$loop_name additional_class=$additional_class}>
      {strip}
      {if $config.Flyout_Menus.icons_disable_subcat_triangle eq 'Y' and $c.subcategory_count gt 0}
        <a href="home.php?cat={$catid}" class="arrow" onclick="javascript: return switchSubcatLayer(this);"></a>
      {/if}
      <!-- current category highlight -->
      {if $current_category.categoryid eq $c.categoryid}
      <a href="home.php?cat={$catid}" style="text-decoration: underline">
      {else}
      <!-- /current category highlight -->
  <a href="home.php?cat={$catid}" class="{if $config.Flyout_Menus.icons_icons_in_categories gte $level+1}icon-link{/if}{if $config.Flyout_Menus.icons_disable_subcat_triangle eq 'Y' and $c.subcategory_count gt 0} sub-link{/if}{if $config.Flyout_Menus.icons_empty_category_vis eq 'Y' and not $c.childs and not $c.product_count} empty-link{/if}{if $config.Flyout_Menus.icons_nowrap_category ne 'Y'} nowrap-link{/if}">
      {/if}
        {$c.category|amp}
        {if $config.Flyout_Menus.icons_display_products_cnt eq 'Y' and $c.top_product_count gt 0}
          ({$c.top_product_count})
        {/if}
      </a>
      {/strip}
      {if $c.childs and $c.subcategory_count gt 0 and ($config.Flyout_Menus.icons_levels_limit eq 0 or $config.Flyout_Menus.icons_levels_limit gt $level)}
        {include file="`$fc_skin_path`/fancy_subcategories_exp.tpl" categories_menu_list=$c.childs parentid=$catid level=$level+1}
      {/if}
    </li>



4. ⌠font-style■ didn▓t work out for "underline" so I changed it to ⌠text-decoration■.



And finally it works! Thank you guys very much for help!

ScrapOrchard 01-29-2011 08:51 AM

Re: Highlight current menu item
 
Fantastic! Thank you!

Don Cornelson 11-18-2011 03:20 PM

Re: Highlight current menu item
 
Anyone know how to do this with 4.1.11? I tried this stuff to no avail. Good info though. Thx

chamberinternet 11-22-2011 05:47 AM

Re: Highlight current menu item
 
Quote:

Originally Posted by qualiteam
You should modify the "skin/common_files/customer/categories.tpl" template and add {if $c.categoryid eq $cat}style="font-style: bold;"{/if} condition into the category rendering loop.


Thanks this works great.
Is it possible to keep the parent category highlighted when a user clicks on a sub-category?


All times are GMT -8. The time now is 05:06 PM.

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