I have the ability to count child pages of the current page via the code below. I'd now like to amend the code so that I can specify a specific page to count from.
#set($pageCount=0)
#foreach ($child in $content.children)
#set($pageCount = $pageCount + 1)
#end
$pageCount
As user macros can use a bunch of Velocity context objects including those in the default Velocity context, you should have access to the `pageManager`.
Using that, something like would work:
#set($pageCount=0)
#set($parentPage = $pageManager.getPage(123)) ## 123 is the ID of the specific page
#foreach ($child in $parentPage.children)
#set($pageCount = $pageCount + 1)
#end
$pageCount
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.