System-asset linking to system-data-structure
Hi There,
I'm writing a Velocity macro to list all of our reusable content pieces on a page.
The macro works, however, I've tried to include a link to the asset itself, and this is where I'm running into an issue.
Example Code:
#set($contactSpifs = $_XPathTool.selectNodes($contentRoot, "//system-block/system-data-structure[@definition-path='page-spifs/contact-spif']"))
<h1>Contact Spifs</h1>
<div class="col col-100">
#foreach($spif in $contactSpifs)
<div class="spifcontainer">
#renderSpif($spif)
#set($link = "" + $spif.parent.parent.getChild('path').value + "")
<a href="[system-asset]${link}[/system-asset]">Link</a>
</div>
#end
</div>
I've tried using the link re-writing, I've tried the system asset in the setting of the $link variable, and within the anchor. In the preview, I get a result like so:
<a href="[system-asset]/_training/common/spifs/Contact Spif - Example[/system-asset]">Link</a>
but in the rendereg html I get <a href="">Link</a>
Any thoughts, tips or tricks are appreciated.
Thanks!
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 11 May, 2016 07:09 PM
Hi Brendon,
What you have should definitely work. Curious, but have you tried using the
link
instead ofpath
? If you are generating these links within a different Site, you will need cross-Site links in order for them to be linked to the correct asset.Thanks!
2 Posted by birwin on 11 May, 2016 07:23 PM
The link didn't work for me either, but when I looked at using the link, it was taking the parent folder's link and then appending the data definitions name so I assumed that was the issue.
I've included a sample xml and heres an example of the script
3 Posted by Ryan Griffith on 16 May, 2016 01:30 PM
Hi Brendon,
Very interesting about using the link. Testing locally, I was not seeing what you described (with the Data Definition name). Here is what I am getting:
Were you able to get things working?
Thanks!
Tim closed this discussion on 27 Jun, 2016 08:56 PM.