Children folders

Tony Jose Ponti's Avatar

Tony Jose Ponti

15 Jul, 2015 04:25 PM

How can I make the following Velocity script for archiving display one level deeper. Currently, it provides me with a link the parent folder's index:
<a href="site://mysite/newsfolder/newsCfolder/2015folder/indexpage">2015</a>. But I'm looking for: <a href="site://mysite/newsfolder/newsCfolder/2015folder/07folder/indexpage">July</a>.


+ formsfolder
- newsfolder
   + newsAfolder
   + newsBfolder
   - newsCfolder
      - 2015folder
                + 07folder (July)
         + 08folder (August)
+ reportsfolder



       #set($parentFolder = $_.locatePage($currentPagePath).parentFolder)

        #set($folders = $parentFolder.children)
        #set($sortedFolders = $_SortTool.sort($folders, "name"))

        #foreach($folderItem in [1..$sortedFolders.size()])
            #set($arrayIndex = $sortedFolders.size() - $foreach.count)
                #set($folder = $sortedFolders[$arrayIndex])

               #set($folderLink = $_EscapeTool.xml($
                | <a href="${folderLink}/index" title="$folder.metadata.title Archived TDI@Work Newletter">$folder.metadata.title</a>
  1. 1 Posted by Ryan Griffith on 15 Jul, 2015 08:43 PM

    Ryan Griffith's Avatar

    Hi Tony,

    You would need to add an additional #foreach within your existing #foreach that loops over the children of the current folder in the loop, or, what I would recommend, is create a macro that accepts a folder node and loops over it's children, while calling itself again. This way you can use recursion to handle traversing the nesting, rather than hardcoding nested #foreach loops which can be problematic and redundant.

    Also, I wanted to note that if you are running Cascade 7.10.1 or newer, you can replace the following line:

    #set($parentFolder = $_.locatePage($currentPagePath).parentFolder)


    #set($parentFolder = $currentPage.parentFolder)

    Please let me know if you have any questions.


  2. 2 Posted by Tony Jose Ponti on 20 Jul, 2015 02:53 PM

    Tony Jose Ponti's Avatar

    Okay. Thank you.

  3. 3 Posted by Ryan Griffith on 20 Jul, 2015 03:35 PM

    Ryan Griffith's Avatar

    Not a problem at all, Tony, glad to hear I was able to help out.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  4. Ryan Griffith closed this discussion on 20 Jul, 2015 03:35 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM