NavTools .active Returning False

9 views
Skip to first unread message

Loren Leonard

unread,
Mar 16, 2022, 3:19:17 PMMar 16
to dotCMS User Group
All of my references to .active are returning false despite being on the child page that I'd like to mark active. Can any of you shed some light on how .active evaluates if it is true?

#foreach($navItem in $navList)
## Find out if children has an active item
#set($childItemActive = 0)
#if ($navItem.children.size() > 0 && $endNavDepth > 1)
#foreach ($childNavItem in $navItem.children)
## these are all evaluating to false
#if ($childNavItem.active)
#set($childItemActive = 1)
#end
#end
#end

Loren Leonard

unread,
Mar 17, 2022, 12:45:27 PMMar 17
to dotCMS User Group
I have decided to re-write this code, we are migrating from an older version of dotCMS. 
The re-write is going well but I have a question. 

Is there a way to return the current pages folder level (as a number)?
I know this will return the path $navtool.getNav() but how can I convert that to a number?


Nathan Keiter

unread,
Mar 29, 2022, 2:44:59 PMMar 29
to dotCMS User Group
Perhaps you could count the number of forward slashes "/" in the result of $navtool.getNav() ?

Nathan I. Keiter | Lead Network Applications Programmer
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu<https://www.gettysburg.edu/>
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of Loren Leonard <leon...@cortland.edu>
Sent: Thursday, March 17, 2022 12:45 PM
To: dotCMS User Group
Subject: [dotcms] Re: NavTools .active Returning False

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
________________________________
#if ($childNavItem.active<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fchildNavItem.active&c=E,1,ekNxx8RhEHqWWJY94Ufk6oac3oJ4jHtplPTsA9Wn1CNioO9ntG8bNs7MEhANRQtJel6Ux7KnYK62r-2povJLMpr8JDAbVUrF_9U7cPySZVuu3eWzx34o&typo=1&ancr_add=1>)
#set($childItemActive = 1)
#end
#end
#end

--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,V0SwZKKhn2HwjwrpRgIfCbchQCCEnmwcX4XySXnngBPl-azEMArFhRMrl2R_6ulKrOL9SpPoDalkDfA6juKFxkPEYTpV3RuWpLS1Bk_956uncC6fv1Tz&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/6a24ea6b-de33-4514-ba07-de91dd581db6n%40googlegroups.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2f6a24ea6b-de33-4514-ba07-de91dd581db6n%2540googlegroups.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,wcU_c-P_54w7VehGOjne0iIiWE7lCMr2PAPz6FPvWHxkhjkFhyKYtVYNAiYzq3AEc3Wn84RRF0wRBOgvaS-cmTk5tgMeNUCnbE4biIj8Kya26N_U7aW6dadcp7go&typo=1>.

Nathan Keiter

unread,
Mar 29, 2022, 2:51:46 PMMar 29
to dotCMS User Group
Without digging into the code, my guess would be that it is some combination of "show on menu" and "is published?".


For example, the old sitemap generator would ignore anything not marked "show on menu". I think it may have used the internal navtools.

Nathan I. Keiter | Lead Network Applications Programmer
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu<https://www.gettysburg.edu/>
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of Loren Leonard <leon...@cortland.edu>
Sent: Wednesday, March 16, 2022 3:15 PM
To: dotCMS User Group
Subject: [dotcms] NavTools .active Returning False

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
________________________________
#if ($childNavItem.active<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fchildNavItem.active&c=E,1,uP4B54knO5_s-pTFx6nr0hWmLkPMZr_jy6oqWts7pq4sD9pknMHleDhibEr1YUazImcbxy11UTMGa9XgRPIp0zuIa86pxOp_5Qv8s1AdLIjXzQ99cdzvZplaUYtV&typo=1&ancr_add=1>)
#set($childItemActive = 1)
#end
#end
#end

--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,ZHSAopMgQx1fnLoqiwj_GodjRK9YWWJo91mmSNpJ3L18OpK8Y0wTIrahHRUsvwOWGMiXAcKK8Xaqg8Mv16RfyjU6Q9CWVetviAQatGzzEFtuiBgpREWRGbAJYOo,&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/2e9bc73d-8868-4cb5-a783-ec3708b35107n%40googlegroups.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2f2e9bc73d-8868-4cb5-a783-ec3708b35107n%2540googlegroups.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,AjEBObiezsVKXzgWdn7_x9KNMxs-EOnNmPsdxeZNR93_DThlKQFg1Fwq0nNrWWRxTU9sy7H91-9I7-sc227nt442IY7tsPQbHadsyXPXr62II3Fp&typo=1>.

Mark Pitely

unread,
Mar 29, 2022, 3:05:11 PMMar 29
to dot...@googlegroups.com
Yes, I think if they are not active, they don't show up in the front end pull.
Here is my ver 21 nav code for reference:
<ul class="page-list mobile-section-nav">
                        <li>
                            <!--- $nav.parent.title  !!! --->
                           #if (!$URLMapContent)
                           
                           <a href="$nav.href" class="current">$nav.title</a>
                           <ul>
                           #foreach ($child in $nav.children)
                           #set ($ncurr="")
                           #if ($child.href.contains($VTLSERVLET_URI))
                           #set ($ncurr="current")
                           #end
                           <li><a href="$child.href" class="$!gncurr">$child.title</a>
                           #if ($child.children && $nav.parent.title!="System folder")
                           <ul>
                                #foreach ($gchild in $child.children)
                                #set ($gncurr="")
                                #if ($gchild.href.contains($VTLSERVLET_URI))
                                #set ($gncurr="current")
                                #end
                                <li><a href="$gchild.href" class="$!gncurr">$gchild.title</a>
                                #end
                           </ul>
                           #end
                           </li>
                           #end
                           </ul>
                           #end
                        </li>
                    </ul>

Mark Pitely
Marywood University

--
http://dotcms.com - Open Source Java Content Management

---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/1648579902428.55999%40gettysburg.edu.

Loren Leonard

unread,
Mar 30, 2022, 1:50:30 PMMar 30
to dotCMS User Group
Yup, I guess I was hoping there was a method that would just return the number for me. Ended up using this:

## Determine the folder depth of the current page by counting "/" in the URI.
#set($pathFolders = $pageURL.split("/"))
#foreach ($pathFolder in $pathFolders)    
     #set($folderNum = $foreach.index - 1)
#end

Mark Pitely

unread,
Mar 30, 2022, 1:52:26 PMMar 30
to dot...@googlegroups.com
You can also do:
#set($pathFolders = $pageURL.split("/"))
$pathFolders.size()

but your method should work fine.

Mark Pitely
Marywood University

Reply all
Reply to author
Forward
0 new messages