show active menu tab when visiting page

Everything to do with Joomla! 3.x templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
freedziner
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Thu Jul 26, 2012 4:43 pm

show active menu tab when visiting page

Post by freedziner » Thu Jun 15, 2017 8:42 pm

I'm running Joomla! 3.7.2.

No matter what page I'm on, the "Home" tab on the main menu shows an active state. One forum member suggested replacing all the class ".active" with a new class ".current". I don't know how "current" is different from "active".

Other advice I read was to go into Extensions, Modules, Main Menu, and set "Base Item" to "current" - but all I can do there is select a Menu Item (one of the articles).

In the Main Menu Advanced panel the Menu class Suffix is " nav-pills" (space in front of "nav"). Module Class Suffix "_menu" and Module Tag "nav".

Could someone please advise?

Thank you!

User avatar
websitedons
I've been banned!
Posts: 389
Joined: Sat May 27, 2017 9:42 am

Re: show active menu tab when visiting page

Post by websitedons » Thu Jun 15, 2017 11:51 pm

Do you have a code inspector on your browser? If yes, right click on the home menu item when on a different page, then view the <li> element that wraps the <a>, and determine if the .active class is included. The .current class is applied to parent items when a child item is active.

freedziner
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Thu Jul 26, 2012 4:43 pm

Re: show active menu tab when visiting page

Post by freedziner » Wed Jun 21, 2017 4:27 pm

Thank you for your reply!

I did what you said and found the current class stays in the list menu item for "Home" no matter what link I'm on.

I have drop-downs, but not on all the menu items. Could this have anything to do with it?

Also, the back-end configuration for Menu Modules has changed in 3.7.2. There is no way to set the Base Item to "Current", so do I have to hard-code the template? If so, won't it change with each update?

jguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon May 08, 2006 1:18 pm
Location: UK

Re: show active menu tab when visiting page

Post by jguy » Fri Jun 23, 2017 9:09 am

I'm working on 3 new Joomla 3.7.2 sites, all using Protostar with just minimal colour changes and have now run into this exact same problem on one of the sites. The one I have the problem with started off on 3.7.1. I'm not too sure when the problem started so I don't know if it was there from the get go. At first I thought it was just with Protostar and spent a lot of time checking out the CSS but I have the same problem with Beez3 and other Bootstrap based templates that I use on other sites. So I am assuming something deeper in Joomla

So much time so much effort and no further. I have now started a fresh site and will have to copy all the content over but I'm nervous because I don't know how this problem was caused and whether it could come back after a this re-build. Its very disconcerting

If anyone has an answer I'm all ears

freedziner
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Thu Jul 26, 2012 4:43 pm

Re: show active menu tab when visiting page

Post by freedziner » Fri Jun 23, 2017 12:43 pm

jguy, I'm not sure when it started either, but I'm past deadline to launch this site and looking all over for a solution. Was tempted to just make a new menu, but don't want to do that and end up with the same result. Surely there's a solution. Please, someone - tell us what it is.

jguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon May 08, 2006 1:18 pm
Location: UK

Re: show active menu tab when visiting page

Post by jguy » Sat Jun 24, 2017 12:42 pm

I was just about to go live too but had to put a stop to that

I did create a whole new second menu structure, but its afflicted with the same problem

Overnight I have been trying to retrace my development steps (restoring each one of my many backups) trying to determine at what point it went wrong, because I only noticed some time later. I may have come across a lead. Early in my setup, I decided to implement the SSL cert that my reseller account has. This is one of those universal ones that is apparently enabled at cPanel account creation time. I have always used individual certs in the past, so had no knowledge this approach and now I'm wondering whether it was at this point things went wrong. After reading up on SSL with regards to Joomla I also turned on the configuration option to "Force SSL to entire site"

Anyway I'm off to remove all these settings and turn off htaccess to see if there is any difference. Will post the result here later

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30809
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: show active menu tab when visiting page

Post by Per Yngve Berg » Sat Jun 24, 2017 12:53 pm

Turn off SEF in Global Configuration and check that htere is an Itemid=xx on the links.

jguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon May 08, 2006 1:18 pm
Location: UK

Re: show active menu tab when visiting page

Post by jguy » Sat Jun 24, 2017 6:58 pm

Well I reverted the whole site back to basic settings including turning off SEF in Global Configuration. The item ids are working fine in non SEF mode but alas no success on any menu tab receiving the active status except for Home tab

freedziner
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Thu Jul 26, 2012 4:43 pm

Re: show active menu tab when visiting page

Post by freedziner » Sun Jun 25, 2017 12:34 am

I found this post under Administration Joomla! 3.x topics and I changed the xml like it instructed, but it didn't work for me: viewtopic.php?t=951300

Someone also gave a link to a patch which I will try to do: https://github.com/joomla/joomla-cms/pull/16459

jguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon May 08, 2006 1:18 pm
Location: UK

Re: show active menu tab when visiting page

Post by jguy » Sun Jun 25, 2017 12:05 pm

I have now also tried that xml change but to no avail

I also noticed another one of my new test sites that I installed quickly a week ago via "installatron" on my hosting has now gone bad in the same way and have no idea why. Something I am doing is triggering this fault

So today I have manually installed Joomla using my own naming standards and usual path obfuscations to see if I can make things go wrong. So far the site is holding up. I have created multiple menus items and have a secondary menu in play with no problems

freedziner
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Thu Jul 26, 2012 4:43 pm

Re: show active menu tab when visiting page

Post by freedziner » Sun Jun 25, 2017 8:16 pm

So the 'current' menu link appears different than the rest of the menu links in the new installation?

jguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon May 08, 2006 1:18 pm
Location: UK

Re: show active menu tab when visiting page

Post by jguy » Sun Jun 25, 2017 10:11 pm

On a fully working site I am getting this style on the active "home" tab "class="item-101 default current active"

While this state is true the other tabs are left plain

If another menu tab other than "home" is current the styling is "item-108 current active"

and the "home" is then styled "item-101 default"

jguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon May 08, 2006 1:18 pm
Location: UK

Re: show active menu tab when visiting page

Post by jguy » Sun Jun 25, 2017 10:18 pm

On my site that has gone bad after a lot of content updates I just didn't want to start from scratch again especially since I can't prevent it happening again I have now installed a menu extension from the Joomla directory called "GiMeSpace Bootstrapped Menu" found at http://joomla.gimespace.com or through the installer

This has added some missing Bootstrap classes and solved the problem for now

freedziner
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Thu Jul 26, 2012 4:43 pm

Re: show active menu tab when visiting page

Post by freedziner » Thu Jun 29, 2017 5:25 am

Well, I downloaded the latest version and started over. The menu is working fine. Unfortunately, I'll never know what caused the other menu to break, since I don't have the time. Thank you to everyone who offered help.

jguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon May 08, 2006 1:18 pm
Location: UK

Re: show active menu tab when visiting page

Post by jguy » Thu Jun 29, 2017 11:17 am

Yes, and not knowing makes future development nervous. I am now backing up on each iteration rather than every few hours of work. Slowly becoming paranoid!

Madeleine
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Thu Nov 01, 2007 5:30 pm

Re: show active menu tab when visiting page

Post by Madeleine » Wed Jan 24, 2018 1:48 pm

I have been having the same problem using ProtoStar on Joomla 3.8.3 with a bilingual site. I ended up having to style the current, active and default classes to get it to highlight the menu tab for the current page and not highlight the menu tab for home when on a different page, but highlight it when on the home page and treat the hover correctly.
This is the code that I put in user.css.

Code: Select all

.nav-pills > .current > a {background: #158cc1; color: #fff;}
.nav-pills > .current > a:hover {background: #fff; color: #000;}
.nav-pills > .default.active > a {background: #fff; color: #158cc1;}
.nav-pills > .default.active > a:hover {background: #fff; color: #000;}
.nav-pills > .default.current.active > a {background: #158cc1; color: #fff;}
Hope this helps somebody, as it took a bit of experimenting to figure out.

jguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Mon May 08, 2006 1:18 pm
Location: UK

Re: show active menu tab when visiting page

Post by jguy » Wed Jan 24, 2018 2:04 pm

Thanks for adding that tip Madeleine

Might need it in the future but so far have not had that problem again with many new sites under the belt

chridevo
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Nov 20, 2007 12:03 am

Re: show active menu tab when visiting page

Post by chridevo » Thu Dec 06, 2018 7:06 am

Thank you Madeleine. Works for me.

OCSC
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Feb 23, 2019 10:20 pm

Re: show active menu tab when visiting page

Post by OCSC » Sat Feb 23, 2019 10:35 pm

I have figured this out! In the modules for the menu, clear the selection so that
Base Item shows as "Current".


Locked

Return to “Templates for Joomla! 3.x”