.active class to static menu

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
qwalk
Forum Members
Forum Members
Posts: 55
Joined: Mon Sep 13, 2010 9:27 am

.active class to static menu

Post by qwalk »

Hi,

I am creating a template without using the {menu}. The menu is designed statically in the template. My code is like this:

Code: Select all

  <div class="menu">
  <ul class="left-col">
   <li>{cms_selflink page="Page1"}</li>
   <li>{cms_selflink page="Page2"}</li>
   <li>{cms_selflink page="Page3"}</li>
  </ul>
  <ul class="right-col">
   <li>{cms_selflink page="Page4"}</li>
   <li>{cms_selflink page="Page5"}</li>
   <li>{cms_selflink page="Page6"}</li>
  </ul>
 </div>
Now, this works fine, but the only problem is, that I want to bold the current active page. Now using the menu manager it was easy because it gave the current page the class .active (or .current, i dont remember), but how do I do the same with this static menu?

Thanks in advance! :)
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: .active class to static menu

Post by Jo Morg »

Maybe by checking {$page_alias} with Smarty conditionals? :)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
qwalk
Forum Members
Forum Members
Posts: 55
Joined: Mon Sep 13, 2010 9:27 am

Re: .active class to static menu

Post by qwalk »

Jo Morg wrote:Maybe by checking {$page_alias} with Smarty conditionals? :)
That is a bit out of my teritory. But I don't think that would work either. You see I have a top menu with 6 links, and each of these links have a submenu. The 6 toplinks aren't really pages, they are only internal page redirectors and redirects to the first link in their submenu. So when clicking on a top level link, it isn't really "active". I don't think it would work even if I was using the menu manager {menu} module.

:/ hmm
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: .active class to static menu

Post by Jo Morg »

Well, I don't know about menu manager; I'm not an expert using it, however with Smarty logic and some help from the CGSimpleSmart module you can get the root page of another page, right from the main template.
This is a little something I wrote some time ago.... Just didn't have the time to finish the site yet.... But it's the same logic.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
qwalk
Forum Members
Forum Members
Posts: 55
Joined: Mon Sep 13, 2010 9:27 am

Re: .active class to static menu

Post by qwalk »

Thank you, I will definitely take a look at it.
oliverseddon
Forum Members
Forum Members
Posts: 89
Joined: Thu Aug 21, 2008 11:47 am

Re: .active class to static menu

Post by oliverseddon »

Could you not just use the {menu} tag but specify your pages?

For example:

<div class="menu">
<div class="left-col">
{menu items='Page1,Page2,Page3'}
</div>
<div class="right-col">
{menu items='Page4,Page5,Page6'}
</div>
</div>
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: .active class to static menu

Post by Dr.CSS »

If you really need to split pages into 2 different UL you could try using the code on this page to change the UL class for each bundle 3...

Of course you will need to remove a bit of the code as it makes numbered navigation for the cycle plugin...

http://how-i-did-that.com/cgblog/4/15/C ... ation.html
Post Reply

Return to “The Lounge”