I have a custom menu - its a module with html links in the .tpl file, set on the website as a block. I wanted to know is it possible to configure drupal so it dynamically add .current class to those links so I can style it when particular page is being viewed. Thanks for help.

2 Answers 2


If you create a new menu and make it a block then it will set a class called "active" when you are on the current page. You will also get a class called "active-trail" for each parent item. If you want to create something more custom then you can check and see if the url matches the link you are building.

You can see here how the menu is being built to get some ideas:


If you want to do something custom then you will need to compare $_GET['q'] to the link that you are building in order to set an active class.

I am pretty sure you can also use theme_item list and the active class will be set:



Also you can use the module menu attributes and at the same time create a custom token that print the class that you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.