Image for listing page
Hello,
On a velocity script, how can I insert an image on the main index listing page that was selected through the data definition of a news article? On the news article pages, I created the option to select an image if the news article has an associated image and aligns it in the article as the final output. That works great on the news article page, but I also want to have the same picture displayed on the main index listing page.
I found this to work for text (outside a group), but can't get the image path to display:
#set($b = $_.locatePage($article.getChild("path").value))
#if(!$_PropertyTool.isNull($b.getStructuredDataNode("altext")))
$_EscapeTool.xml($b.getStructuredDataNode("altext").textValue)
I have two asset type="file" (one inside a group and other outside a group), but it don't matter if the final asset chooser for the image picker is in or outside a group. I was trying it both ways:
<system-data-structure>
<group identifier="insert" label="Newsletter Image">
<text type="radiobutton" identifier="display" label="Display" default="Off">
<radio-item value="On"/>
<radio-item value="Off"/>
</text>
<text identifier="alt" label="Alt Text"/>
<asset type="file" identifier="image"/>
</group> <text identifier="altext" label="Alt"/>
<asset type="file" identifier="graphic" label="Graphic"/>
<text wysiwyg="true" identifier="content" label="Content"/>
</system-data-structure>
Thank you,
Tony Ponti
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 22 Jun, 2015 05:40 PM
Hi Tony,
Using the
image
field, the following should output an image if one is chosen for that field:Note: if you would like to make the image's src attribute a cross-Site link, you can also append the Site name onto the front:
Please let me know if you have any questions.
Thanks!
2 Posted by Tony Jose Ponti on 22 Jun, 2015 06:26 PM
Ryan,
I used your code, but it didn’t work. It’s similar to an example I tried that you had on: http://help.hannonhill.com/discussions/velocity-formats/11508-getting-image-path .
Does $b need to be changed? I don’t think $b is referenced anywhere else on the script. My loop is: #foreach($article in $articles)
-Tony
3 Posted by Tony Jose Ponti on 22 Jun, 2015 06:36 PM
Ryan,
Please disregard my last email. I accidently deleted:
#set($b = $_.locatePage($article.getChild("path").value))
It’s working great now. Sorry about the confusion. Thanks for all your help.
-Tony
From: Tony Jose Ponti
Sent: Monday, June 22, 2015 1:26 PM
To: 'Ryan Griffith'
Subject: RE: Image for listing page [Velocity Formats #12068]
Ryan,
I used your code, but it didn’t work. It’s similar to an example I tried that you had on: http://help.hannonhill.com/discussions/velocity-formats/11508-getting-image-path .
Does $b need to be changed? I don’t think $b is referenced anywhere else on the script. My loop is: #foreach($article in $articles)
-Tony
4 Posted by Ryan Griffith on 22 Jun, 2015 07:44 PM
Thank you for following up, Tony, I am glad to hear my proposed change did the trick.
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 22 Jun, 2015 07:44 PM.