Dynamic Titles and active status for Navigation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic Titles and active status for Navigation

Neelam Mehta
Hi ,

I am new to thymeleaf . I have existing project that we are migrating from JSF to Spring MVC 3 + thymeleaf as the view layer.

the issue I am currently facing is that I need to have dynamic title and change the state of nav bar so that it can highlighted...

I have look at the layout dialect ... I can achieve the dynamic title but I am not sure about the nav bar ... I do not want the controller to send me the value ...

as i know I am on the page .. I want to define them in the html and achieve the desired behavior.

Thanks,
Neelam
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Titles and active status for Navigation

Emanuel
Administrator
Are you able to know what part of your navigation to highlight based on the URL?  If so, you could probably check the URL and alter your nav items accordingly, eg:

<li class="nav-item" th:classappend="${(#httpServletRequest.requestURL.toString().contains('home')) ? 'selected'}">