[Skip to main content](#vessel-content)

#   Styling "select" state for menu items (categories)

##

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago -  14 years 11 months ago [\#29945](#29945) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  *[Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#29945 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")* was created by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")*

Any suggestions for creating a select state for category menu items?

I have a nicely functioning menu showing my product categories and I would like to "highlight" the item that corresponds to the category being viewed.

I don't see any "hooks" being generated by the code, I was wondering if you had any suggestions on how to implement this.

This image shows a selected category, but no select state to identify the category chosen
[ ![&#91;img](http://www.hikashop.com/media/kunena/attachments/legacy/images/no-select_menu.jpg) ](http://www.hikashop.com/media/kunena/attachments/legacy/images/no-select_menu.jpg "&#91;img")

This is my rollover, and hopefully select state as well
[ ![&#91;img](http://www.hikashop.com/media/kunena/attachments/legacy/images/select_menu.jpg) ](http://www.hikashop.com/media/kunena/attachments/legacy/images/select_menu.jpg "&#91;img")

Thanks again

- [ ![select&#95;menu.jpg](/forum/attachment/2067) ](/forum/attachment/2067 "select&#95;menu.jpg") [ ](/forum/attachment/2067?download=1 "select&#95;menu.jpg")

Last edit: 14 years 11 months ago by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago [\#29946](#29946) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#29946 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

First image should have been
[ ![&#91;img](http://www.hikashop.com/media/kunena/attachments/legacy/images/no_select_menu.jpg) ](http://www.hikashop.com/media/kunena/attachments/legacy/images/no_select_menu.jpg "&#91;img")

I'm sure you get the idea

- [ ![no&#95;select&#95;menu.jpg](/forum/attachment/2068) ](/forum/attachment/2068 "...elect&#95;menu.jpg") [ ](/forum/attachment/2068?download=1 "...elect&#95;menu.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86282
- Thank you received: 14262
-
-

14 years 11 months ago [\#29967](#29967) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#29967 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Hi,

Menus items are entirely controlled by joomla so there is no control on that on HikaShop's end.

I don't know if it would be possible and how as I don't know much about template design for joomla menus so I'm afraid I can't help you.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago [\#29976](#29976) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#29976 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Thanks again , but that doesn't exactly seem right, since the menu in question is being written directly by a hikashop file. View &gt; category &gt; listing_list.php I have verified that this is indeed the file that creates the category menu... in list format anyways.

An excerpt from the file in question:

...
foreach($this-&gt;rows as $row){
$link = hikashop_completeLink('category&amp;task=listing&amp;cid='.$row-&gt;category_id.'&amp;name='.$row-&gt;alias.$this-&gt;menu_id);
?&gt;
&lt;li class="hikashop_category_list_item" &lt;?php echo $width; ?&gt;&gt;
&lt;a href="&lt;?php echo $link; ?&gt;" &gt;
&lt;?php echo $row-&gt;category_name; ?&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;?php
}

It's kinda weird, styling a width. Joomla will usually add an "current active" class to a menu item in the selected state.

And the code being generated follows (this is my category menu):

...
div class="hikashop_subcategories_listing"&gt;
&lt;div class="hikashop_subcategories"&gt;

&lt;ul class="hikashop_category_list"&gt;

&lt;li class="hikashop_category_list_item" style="width:100%;"&gt;
&lt;a href="/index.php/2011-11-13-06-55-33/category/12-2-piece-diffuser-sets"&gt;
&lt;/li&gt;

&lt;li class="hikashop_category_list_item" style="width:100%;"&gt;
&lt;a href="/index.php/2011-11-13-06-55-33/category/13-3-piece-diffuser-sets"&gt;
&lt;/li&gt;

&lt;li class="hikashop_category_list_item" style="width:100%;"&gt;
&lt;a href="/index.php/2011-11-13-06-55-33/category/14-truly-unique-diffusers"&gt;
&lt;/li&gt;

&lt;/ul&gt;
&lt;/div&gt;

An active class should be added to the active item

On my main menu, Joomla does this (see item 103 below)

...
&lt;div id="menu"&gt;
&lt;ul class="menu"&gt;
&lt;li class="item-118"&gt;
&lt;a href="/index.php/checkout"&gt;Checkout&lt;/a&gt;
&lt;/li&gt;
&lt;li class="item-104"&gt;
&lt;a href="/index.php/2011-11-13-06-56-34"&gt;Contact&lt;/a&gt;
&lt;/li&gt;
&lt;li class="item-102"&gt;
&lt;a href="/index.php/about"&gt;About&lt;/a&gt;
&lt;/li&gt;
&lt;li class="item-103 current active"&gt;
&lt;a href="/index.php/2011-11-13-06-55-33"&gt;Shop&lt;/a&gt;
&lt;/li&gt;
&lt;li class="item-101"&gt;
&lt;a href="/"&gt;Home&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

That "current active" class makes styling it really simple

Now I noticed that there were several ways of generating a category menu, this one is actually a Joomla menu, but all the links are generated by HikaShop...

Again, any suggestions would be appreciated.

PS, the demo shop does seem to accomplish a selected state, which method was used? ( There are a couple ways to make a category menu right?)

Cheers!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago [\#29981](#29981) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#29981 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Actually the demo succeeds in showing the proper active state... except when the sliding product module at top is used... that doesn't seem to update the proper category on the menu.

I thought of an easy solution for my question though( I think. Just need a little help.

If I could pass a variable (or rather, capture one already in use) based on a given category being selected, that should be an easy way to implement a custom css style for a selected category. Better yet, a category id would be perfect. (no spaces in the name...)

I'm just not sure what variables exist that I could use. My theory is to grab it and echo it as a class onto my body tag. Then use css to style a given menu item based on that

Can you recommend to me what variable exists to do so? Then I could do something like the following-

\#shop .category_id1234 #category-menu .hikashop_category_list_item a{
background-image: url(../images/cat-menu-bg-selected.gif);
color: #FFF;
}

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86282
- Thank you received: 14262
-
-

14 years 11 months ago [\#29996](#29996) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#29996 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Ok, so if your 'menus' are displayed by HikaShop, they are not menus but a HikaShop categories listing module, which is indeed displayed by HikaShop. And we can help you on that ![:)](/media/kunena/emoticons/8.png ":)")

It's normal that the width is set directly in PHP. That's because you can select the number of columns of your listing. So that parameter needs to be dynamic because it will vary based on the number of columns. As you have 1 column for that listing, the width is set to 100%.

There is indeed no mechanism to have the current/active category selected for the layout you're using. That would be a nice addition though.
You need to change the code:
?&gt;
&lt;li class="hikashop_category_list_item" &lt;?php echo $width; ?&gt;&gt;

to:
$class = '';
if(JRequest::getString('option',HIKASHOP_COMPONENT) &amp;&amp; JRequest::getString('ctrl','category') &amp;&amp; $cid = JRequest::getInt('cid',0) &amp;&amp; $cid == $row-&gt;category_id){
$class=' current active';
}
?&gt;
&lt;li class="hikashop_category_list_item&lt;?php echo $class; ?&gt;" &lt;?php echo $width; ?&gt;&gt;

in that file and that should add the classes like for joomla menus.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago [\#30065](#30065) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30065 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Thanks Nicolas-

I inserted the code, but it seems $class is returning empty

here's the code:

foreach($this-&gt;rows as $row){
$link = hikashop_completeLink('category&amp;task=listing&amp;cid='.$row-&gt;category_id.'&amp;name='.$row-&gt;alias.$this-&gt;menu_id);

$class = '';
if(JRequest::getString('option',HIKASHOP_COMPONENT) &amp;&amp; JRequest::getString('ctrl','category') &amp;&amp; $cid = JRequest::getInt('cid',0) &amp;&amp; $cid == $row-&gt;category_id){
$class=' current active';
}
?&gt;
&lt;li class="hikashop_category_list_item&lt;?php echo $class; ?&gt;" &lt;?php echo $width; ?&gt;&gt;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86282
- Thank you received: 14262
-
-

14 years 11 months ago [\#30078](#30078) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30078 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Indeed. It should be:
if(JRequest::getString('option',HIKASHOP_COMPONENT) &amp;&amp; JRequest::getString('ctrl','category') &amp;&amp; JRequest::getInt('cid',0) == $row-&gt;category_id){

instead of:
if(JRequest::getString('option',HIKASHOP_COMPONENT) &amp;&amp; JRequest::getString('ctrl','category') &amp;&amp; $cid = JRequest::getInt('cid',0) &amp;&amp; $cid == $row-&gt;category_id){

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago [\#30083](#30083) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30083 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

That did it, much thanks! ![:)](/media/kunena/emoticons/8.png ":)")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago [\#30090](#30090) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30090 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Well, on further examination it actually works only partially... there is something weird happening on the product pages.

The active state does work for the category pages, and on ONE of my product pages, but none of the others :blink:

I have 6 products in a given category. From my category page, when I click one of the products the active class remains, but for the other 5 products, the active class disappears.... I have re-ordered the products in HikaShop admin and the same single product continues to show the active category menu but none of the others do.

The fact that this does work for one of the products and not the others is perplexing to me.

Any suggestions for that one? :side:

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86282
- Thank you received: 14262
-
-

14 years 11 months ago -  14 years 11 months ago [\#30092](#30092) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30092 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Yes, that modification does not work on other pages than the categories pages.

To have it working like on the demo website, the code will be a bit more complex:

$class = '';
if(JRequest::getString('option',HIKASHOP_COMPONENT)){
$app =&amp; JFactory::getApplication();
if(JRequest::getInt('cid',0) == $row-&gt;category_id){
$class=' current active';
$app-&gt;setUserState(HIKASHOP_COMPONENT.'.last_category_selected',$row-&gt;category_id);
}elseif($app-&gt;getUserState(HIKASHOP_COMPONENT.'.last_category_selected')==$row-&gt;category_id){
$class=' current active';
}
}
?&gt;
&lt;li class="hikashop_category_list_item&lt;?php echo $class; ?&gt;"&gt;

Last edit: 14 years 11 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago -  14 years 11 months ago [\#30100](#30100) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30100 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

That almost did it!

If I'm on a category or item page, and click on the link of another category I end up with 2 active states! That lasts until I click on another category menu or an item link, at which time only the correct active state shows

Also, if I use my main menu to visit my contact page or home page, the previously selected active state remains, which is not quite right.

Sorry to be a pain.. :S

Is there a way to reset that so only one active item shows at a time, or none if I visit another page?

Last edit: 14 years 11 months ago by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86282
- Thank you received: 14262
-
-

14 years 11 months ago [\#30114](#30114) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30114 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

That's also possible but again it complexifies the code.
Attached is the solution for that.

####  *This attachment is hidden for guests.
Please log in or register to see it.*

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago [\#30176](#30176) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30176 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Thanks again Nicolas, that does fix the issue of double select states on product or category pages.

It does leave me with a select state when I navigate away from my products and visit my contact page or home page, which show no products... it would be great if the category menu reset itself in those situations.
[ ![&#91;img](http://www.hikashop.com/media/kunena/attachments/legacy/images/select_state_showing_wrong.jpg) ](http://www.hikashop.com/media/kunena/attachments/legacy/images/select_state_showing_wrong.jpg "&#91;img")

The active state is being "remembered" in those cases - the $class is not reset to clear. Or is it the $found variable? I'm not sure. Tried to alter the code, but the conditionality is beyond me.

Is there a simple way to clear those (if applicable)?

Thanks again for all your help

- [ ![select&#95;state&#95;showing&#95;wrong.jpg](/forum/attachment/2079) ](/forum/attachment/2079 "...wing&#95;wrong.jpg") [ ](/forum/attachment/2079?download=1 "...wing&#95;wrong.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago [\#30195](#30195) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30195 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Well, I did find a partial solution, based on setting an id for my body based on my main menu.

I already control my body id using a parameter I pass from my main menu:
...
&lt;?php
$menu =&amp; JSite::getMenu();
$active = $menu-&gt;getActive();
$params = $menu-&gt;getParams( $active-&gt;id );
$class = $params-&gt;get( 'pageclass_sfx' );
?&gt;
&lt;/head&gt;

&lt;body id ="&lt;?php echo $class ? htmlspecialchars($class) : ''; ?&gt;"&gt;

So if I do this for my style:
\#shop #category-menu .current a {
background-image: url(../images/cat-menu-bg-selected.gif);
}

then I have effectively narrowed down my category menu select states only to my "shop" pages.

Yes!

The reason it's only partially perfect is because:

1. If I do visit my Shop page after viewing an item or category page, then the previously selected category menu item is highlighted, which it should not.

2. If I select an item from within the cart/checkout page itself, then the effective hierarchy becomes home &gt; checkout &gt; product, and while the product shows, the corresponding category menu item is not active. But that's a Joomla thing I believe, and while less than optimal is not a show stopper.

It still would be optimal if that $class or $found could forget the previously selection on page load if my main menu was used(

If you have another suggestions... on how to clear that $class ![B)](/media/kunena/emoticons/1.png "B)")

Image showing category menu in select state when viewing Shop page (No category selected - category menu is remembering the earlier selection before navigating to another main menu item page)
[ ![&#91;img](http://www.hikashop.com/media/kunena/attachments/legacy/images/shop_page_select_state_on.jpg) ](http://www.hikashop.com/media/kunena/attachments/legacy/images/shop_page_select_state_on.jpg "&#91;img")

- [ ![shop&#95;page&#95;select&#95;state&#95;on.jpg](/forum/attachment/2080) ](/forum/attachment/2080 "...t&#95;state&#95;on.jpg") [ ](/forum/attachment/2080?download=1 "...t&#95;state&#95;on.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86282
- Thank you received: 14262
-
-

14 years 11 months ago [\#30196](#30196) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30196 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

You can use that file instead for that.

####  *This attachment is hidden for guests.
Please log in or register to see it.*

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago [\#30198](#30198) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30198 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

No joy there, same result. $found still seems to be remembering the last state, despite setting it to nothing.

Despite setting $found =''; when it's called again with

$found = $app-&gt;getUserState(HIKASHOP_COMPONENT.'.last_category_selected

the ".last_category_selected" state seems to be persistent, making the preceding $found =''; irrelevant.

Would it be possible to do something like:

if(JRequest::getString('option',***NOT*** HIKASHOP_COMPONENT)){
$found = '';

?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86282
- Thank you received: 14262
-
-

14 years 11 months ago [\#30200](#30200) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30200 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Ah yes, the check should actually be:

if(JRequest::getString('option')==HIKASHOP_COMPONENT){

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")**
- [![sdebaun's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4429.png)](/forum/user/4429-sdebaun "View sdebaun's Profile") Topic Author
- [ Offline](/forum/user/4429-sdebaun)

Less More

- Posts: 38
- Thank you received: 0
-
-

14 years 11 months ago [\#30207](#30207) by [sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")  Replied by *[sdebaun](/forum/user/4429-sdebaun "View sdebaun's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30207 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Almost.. :blush:

Well, that does solve the issue on non HikaShop pages like Home, About and Contact, but on the Checkout, and Shop page (no category selected - yet) the previous selected category is again "remembered" when visiting those pages because they are registering as hikashop components. Is there a way to be more selective, say not just any hikashop component, but a category or product view within the hikashop component?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86282
- Thank you received: 14262
-
-

14 years 11 months ago [\#30208](#30208) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Styling "select" state for menu items (categories)](/forum/4-how-to/29945-styling-select-state-for-menu-items-categories#30208 "Any suggestions for creating a select state for category menu items?  I have a nicely functioning menu showing my product categories and I would like to &quot;highlight&quot; the item that corresponds to the category being viewed.  I don't see any &quot;hooks&quot; being generated by the code, I was wondering if you had any suggestions on how to implement this.  This image shows a selected category, but no select state to identify the category chosen  This is my rollover, and hopefully select state as well  Thanks again")*

Please try with that check instead then:
if(JRequest::getString('option')==HIKASHOP_COMPONENT &amp;&amp; in_array(JRequest::getString('ctrl','category'),array('category','product'))){

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5OTQ1LXN0eWxpbmctc2VsZWN0LXN0YXRlLWZvci1tZW51LWl0ZW1zLWNhdGVnb3JpZXM/c3RhcnQ9MCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.506 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
