Multi-lingual Navigation


Here is an example of how to do multi-lingual navigation using the navtool. You need to have your language keys set up and then make each page title a language key and then the following should work.


${esc.h}set(${esc.d}list = ${esc.d}navtool.getNav("/"))
${esc.h}foreach(${esc.d}n in ${esc.d}list)
	<li class="divider"></li>
	${esc.h}set(${esc.d}children = ${esc.d}n.children)
	${esc.h}if(${esc.d}children && ${esc.d}children.size() > 0)
		<li class="has-dropdown ${esc.h}if(${esc.d} active ${esc.h}end">
			<a href="${esc.d}{n.href}">${esc.d}text.get( ${esc.d}{n.title} )</a>
			<ul class="dropdown">
				${esc.h}foreach(${esc.d}ch in ${esc.d}children)
					<li ${esc.h}if(${esc.d} class="active" ${esc.h}end><a href='${esc.d}{ch.href}'>${esc.d}text.get( ${esc.d}{ch.title} )</a></li>
		<li class="${esc.h}if(${esc.d} active ${esc.h}end"><a href='${esc.d}{n.href}'>${esc.d}text.get( ${esc.d}{n.title} )</a></li>

Have you created code you'd like to share with the dotCMS community?

Share your code Become a Contributor