
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 08:06 AM
Hello community,
Is it possible to apply a specific CSS class for the menu item of the active page ?
Regards
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018 05:58 AM
Hi everyone and thanks a lot for your answers.
Finally, we have found a solution to apply a specific CSS class on the menu item link active based on the current page ID.
To do it, we just added this code in the CSS include of the theme :
.navbar-nav > li > a.active {
color: #f00;
}
The widget "Header Menu" compute the menu content and use the related ng-template "menuTemplate" to generate all menu items HTML.
So, in the menuTemplate ng-template, we have replaced
<a ng-if="item.items.length == 0 && !item.scriptedItems" ng-href="{{item.href}}" target="{{item.url_target}}" title="{{item.hint}}" >
<fa ng-if="item.glyph" name="{{::item.glyph}}"></fa>
<span ng-bind-html="item.label"></span>
</a>
By
<a ng-if="item.items.length == 0 && !item.scriptedItems" ng-href="{{item.href}}" target="{{item.url_target}}" title="{{item.hint}}" ng-class="{ 'active':item.href.indexOf('?id='+$root.page.id) >= 0 } ">
<fa ng-if="item.glyph" name="{{::item.glyph}}"></fa>
<span ng-bind-html="item.label"></span>
</a>
It works fine.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2018 07:27 AM
Thank you for posting your solution, this works for me in /SP however I'm unable to get it to work in /CSM portal
The conditional is such that page.id and the item.href must be the same to display .active
In /csm the url's contain additional parameters than the page.id which voids the condition and fails to render .active
I'm not an angular ninja so I'm scratching my head on how to accomplish this.
Has anyonone else been able to get this to work in /CSM? Thanks in advance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2018 02:40 AM
Hi Mike,
I have checked my solution in CSM and it's not working very well because the URL contains many parameters.
So I have found an improvement to resolve it and I have updated my previous post ;-). Look at the message.
If you want to use it for CSM, you can modify the menuTemplate and add the CSS style in the CSS include of the CSM theme (eg. customer-service-styles.css ).
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2018 07:35 AM
I am humbled and grateful for your guidance. This works perfectly and appears to be the most elegant solution. Thank you Chritophes!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 09:25 AM
Hi Christophes, I'm looking to do your solution...the bit where you say:
"So, in the menuTemplate ng-template, we have replaced"
where is this done?
thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 09:27 AM