Children folders
Hello,
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>
.
----structure----
+ formsfolder
- newsfolder
+ newsAfolder
+ newsBfolder
- newsCfolder
- 2015folder
+ 07folder (July)
index
+ 08folder (August)
indexpage
+ reportsfolder
----script----
<br/><p><strong>Archives</strong>
#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)
#if($sortedFolders[$arrayIndex].children)
#set($folder = $sortedFolders[$arrayIndex])
#set($folderLink = $_EscapeTool.xml($folder.link))
| <a href="${folderLink}/index" title="$folder.metadata.title Archived TDI@Work Newletter">$folder.metadata.title</a>
#end
#end
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | 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
1 Posted by Ryan Griffith on 15 Jul, 2015 08:43 PM
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:
with:
Please let me know if you have any questions.
Thanks!
2 Posted by Tony Jose Ponti on 20 Jul, 2015 02:53 PM
Okay. Thank you.
3 Posted by Ryan Griffith on 20 Jul, 2015 03:35 PM
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!
Ryan Griffith closed this discussion on 20 Jul, 2015 03:35 PM.