Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Highlight current menu item

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-24-2011, 01:46 PM
  Wazowski's Avatar 
Wazowski Wazowski is offline
 

Advanced Member
  
Join Date: Jan 2011
Posts: 51
 

Question Highlight current menu item

Hello!

How do I make the menu to highlight the category where I▓m currently in (underline, bold)?
__________________
X-Cart version 4.5.5
Reply With Quote
  #2  
Old 01-27-2011, 04:14 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following user thanks qualiteam for this useful post:
Wazowski (01-29-2011)
  #3  
Old 01-27-2011, 01:08 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default 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.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following user thanks cherie for this useful post:
Wazowski (01-29-2011)
  #4  
Old 01-27-2011, 06:40 PM
  Wazowski's Avatar 
Wazowski Wazowski is offline
 

Advanced Member
  
Join Date: Jan 2011
Posts: 51
 

Default 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}
__________________
X-Cart version 4.5.5
Reply With Quote
  #5  
Old 01-27-2011, 07:35 PM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default 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}
__________________
xcartmods.co.uk
Reply With Quote

The following 2 users thank PhilJ for this useful post:
ScrapOrchard (01-29-2011), Wazowski (01-29-2011)
  #6  
Old 01-28-2011, 02:29 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Highlight current menu item

Close!
Code:
{if $current_category.categoryid eq $c.categoryid}
I think that's what you meant.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following user thanks cherie for this useful post:
ScrapOrchard (01-29-2011)
  #7  
Old 01-29-2011, 12:08 AM
  Wazowski's Avatar 
Wazowski Wazowski is offline
 

Advanced Member
  
Join Date: Jan 2011
Posts: 51
 

Thumbs up 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!
__________________
X-Cart version 4.5.5
Reply With Quote
  #8  
Old 01-29-2011, 08:51 AM
 
ScrapOrchard ScrapOrchard is offline
 

eXpert
  
Join Date: Mar 2008
Posts: 243
 

Default Re: Highlight current menu item

Fantastic! Thank you!
__________________
www.scraporchard.com
X-Cart Pro Version 4.5.5

Altered Cart: One Page Checkout, OnSale, Buy Together, Download Expander, Smart Search, Shop by Filters
Gahela: Gahela Support System
The xCart Store: xBanners, xAccess, xMenus
Reply With Quote
  #9  
Old 11-18-2011, 03:20 PM
 
Don Cornelson Don Cornelson is offline
 

Newbie
  
Join Date: Sep 2008
Posts: 8
 

Default 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
__________________
4.1.11
x-SpecialOffers
Reply With Quote
  #10  
Old 11-22-2011, 05:47 AM
  chamberinternet's Avatar 
chamberinternet chamberinternet is offline
 

X-Wizard
  
Join Date: Sep 2005
Location: Lancashire, UK
Posts: 1,470
 

Default 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?
__________________
Developing in 4.7.x now (Dipping into v5 - Slowly!)
Have used 4.1.x, 4.2.x, 4.4.x, 4.5.x, 4.6.x & 4.7.x
Multiple Instances of X-Cart
MySQL 5.6.37
CentOS 7.4


Chamber Internet
- Lancashire, United Kingdom
http://www.chamberelancs.co.uk
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:39 AM.

   

 
X-Cart forums © 2001-2020