Get path data from a page other than the calling page?
I still a little confused about accessing data from a page in Cascade.
I have a page that is supposed to pull in thumbnail images and
headlines from news articles (pages) that are actually stored in a
directory that is a sibling of the index page for a "News"
directory. I have an Folder Index block attached and a format and
it seems to pull in the news article data-definition elements, but
I need the path for the actual news article page, which is not
within the data definition elements.
Is there an easy way to understand how this works?
In my Velocity I am iterating over a collection of pages that I am pulling in structured-data, but I can't of course get the url of each page in the foreach? can I?
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
Support Staff 1 Posted by Tim on 05 Aug, 2016 08:07 PM
Hi,
Since you mentioned that it is pulling in the Data Definition elements, it sounds like you may already have a render-content-depth setting that is allowing the chooser to render the data that you need.
The path of the page itself will not be in the data definition content. Instead, it should be included directly under the
<system-page>
tag. When you have a moment, can you edit your Index Block (the one that you're selecting) and verify that the Indexed Asset Content field has Regular Content checked? This is the setting that forces the Index Block to output the<path>
and<link>
elements.Let me know what you find.
Thanks
2 Posted by voltmer1 on 05 Aug, 2016 08:14 PM
I guess I just don't know how to access that once inside a loop of data-definitions. Here is my index and a snip of the VTL.
3 Posted by Ryan Griffith on 05 Aug, 2016 08:40 PM
Hi,
When working with choosers, you are actually given direct access to the chosen asset's API object. So, rather than using
.textValue
, you would use.asset
along with whatever property you wish to access. I would suggest first testing to make sure an asset is selected.For example, let's assume you have the image chooser field saved to the variable
$image_field
:Please let me know if you have any questions.
Thanks!
4 Posted by voltmer1 on 11 Aug, 2016 01:08 PM
Ryan,
I've tried using the .asset.path and it doesn't return anything.
5 Posted by Ryan Griffith on 11 Aug, 2016 03:34 PM
Hi,
As I mentioned previously, you will need to reference the actual chooser field in order to use
.asset.link
. For example, the code I provided earlier:Please let me know if you have any questions.
Thanks!
6 Posted by voltmer1 on 11 Aug, 2016 04:25 PM
but Ryan, I don't have the chooser field with the page path. I am trying to reference the path to pages that are in a directory of "news-articles", not a field.
7 Posted by Ryan Griffith on 15 Aug, 2016 12:33 PM
Ah, my apologies, I thought you needed the link for a chosen asset. In that case, try dropping the
.asset
from the snippet you provided earlier:Please let me know if you have any questions.
Thanks!
8 Posted by voltmer1 on 15 Aug, 2016 04:17 PM
Thanks Ryan! Worked perfectly. I am also trying to get a thumbnail that is an "asset" assigned within the data definition using your earlier suggestion, with no success. Is this the correct way to do this?
9 Posted by voltmer1 on 15 Aug, 2016 07:03 PM
Sorry Ryan, I didn't see the earlier post (this works):
Thanks again! I guess I don't understand when to use the different methods.
10 Posted by Ryan Griffith on 15 Aug, 2016 07:49 PM
Not a problem at all. I am glad to hear the proposed snippet did the trick.
When in doubt, you can always use the
$_PropertyTool.outputProperties()
method on any object to see what properties and methods are available to you.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 15 Aug, 2016 07:49 PM.