tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/14471-get-path-data-from-a-page-other-than-the-calling-pageCascade CMS: Discussion 2016-08-15T19:49:56Ztag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-05T18:50:46Z2016-08-05T20:06:55ZGet path data from a page other than the calling page?<div><p>I still a little confused about accessing data from a page in
Cascade.</p>
<p>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.<br>
Is there an easy way to understand how this works?</p>
<p>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?</p></div>voltmer1tag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-05T20:07:18Z2016-08-05T20:07:18ZGet path data from a page other than the calling page?<div><p>Hi,</p>
<p>Since you mentioned that it <em>is</em> pulling in the Data
Definition elements, it sounds like you may already have a
<em>render-content-depth</em> setting that is allowing the chooser
to render the data that you need.</p>
<p>The path of the page itself will not be in the data definition
content. Instead, it should be included directly under the
<code><system-page></code> tag. When you have a moment, can
you edit your Index Block (the one that you're selecting) and
verify that the <strong>Indexed Asset Content</strong> field has
<strong>Regular Content</strong> checked? This is the setting that
forces the Index Block to output the <code><path></code> and
<code><link></code> elements.</p>
<p>Let me know what you find.</p>
<p>Thanks</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-05T20:14:18Z2016-08-05T20:14:18ZGet path data from a page other than the calling page?<div><p>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.</p>
<pre>
<code>#set ( $news_list_page = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page") )
#set ( $news_list_page_metadata = $news_list_page.getChildren('dynamic-metadata') )
#set ( $query = $_.query() )
#set ( $query = $query.byMetadataSet("Main-Taxonomy-List") )
#set ( $query = $query.byContentType("news-detail") )
#set ( $query = $query.includePages(true) )
#set ( $query = $query.includeFiles(false) )
#set ( $query = $query.includeBlocks(false) )
#set ( $query = $query.includeFolders(false) )
#set ( $query = $query.includeSymlinks(false) )
#set ( $query = $query.sortBy("created") )
#set ( $query = $query.sortDirection("desc") )
#set ( $query = $query.maxResults(12) )
#set ( $news = $query.execute() )
<div class="region news-list-region">
<div class="region-holder">
<!-- Filter form -->
<form class="filter-form">
<div class="filter-form-holder">
<div class="filter-form-item">
<span class="filter-form-label">Search by:</span>
</div>
<div class="filter-form-item">
<div class="filter-form-select-wrapper">
<select class="filter-form-select" name="" id="select-1">
<option value="Recent news">Recent news</option>
<option value="2015-2016">2015-16</option>
<option value="2014-2015">2014-15</option>
<option value="2013-2014">2013-14</option>
</select>
</div>
</div>
<div class="filter-form-item">
<div class="filter-form-select-wrapper">
<label for="topics" class="hide-for-screen-reader">Please choose topic</label>
<select class="filter-form-select" name="topics" id="topics">
<option value="All Topics">All Topics</option>
#foreach( $news_items as $news_list_page_metadata )
#if( 'news-and-events' == $news_items.getChild('name').value )
#set( $taxonomy_list = $news_items.getChildren('value') )
#foreach( $taxonomy_item as $taxonomy_list )
<option value="$taxonomy_item.value">$taxonomy_item.value</option>
#end
#end
#end
</select>
</div>
</div>
<div class="filter-form-item">
<button type="submit" class="filter-form-btn btn btn-primary">Search</button>
</div>
</div>
</form>
<!-- News list -->
<ul class="news-list">
#foreach( $single_news in $news )
#set( $headline = $single_news.getStructuredDataNode('headline').textValue )
#set( $byline = $single_news.getStructuredDataNode('byline').textValue )
#set( $calendar = $single_news.getStructuredDataNode('calendar').textValue )
#set( $thumbnail_image = $single_news.getStructuredDataNode('thumbnail-image').textValue )
#set( $news_link = $single_news.getChild('link').value )
#set( $metadata = $single_news.metadata )
#set( $dynamic_fields = $metadata.dynamicFields )
<li class="news-list-item">
<article class="news-block is-blue">
<div class="news-block-holder">
#set( $stop_loop = false )
#if( $dynamic_fields.size() > 0 )
#foreach( $dynamic_field in $dynamic_fields )
#set( $chanwTextSize = $dynamic_field.Values.size() )
#if( $chanwTextSize > 0 )
#foreach( $value in $dynamic_field.Values )
#if( $value != "" )
<strong class="news-block-taxonomy">$value</strong>
#set( $stop_loop = true )
#break
#end
#end
#end
#if( $stop_loop )
#break
#end
#end
#end
<div class="news-block-img">
#if( ! $thumbnail_image )
#set( $thumbnail_image = '/assets/images/img-news-list-01.jpg' )
#end
<img src="$thumbnail_image" alt="News Image" /> </div>
<div class="news-block-body">
<a href="${news_link}" class="news-block-link">$headline</a>
</div>
</div>
</article>
</li>
#end
</ul></code>
</pre></div>voltmer1tag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-05T20:40:24Z2016-08-05T20:40:24ZGet path data from a page other than the calling page?<div><p>Hi,</p>
<p>When working with choosers, you are actually given direct access
to the chosen asset's API object. So, rather than using
<code>.textValue</code>, you would use <code>.asset</code> along
with whatever property you wish to access. I would suggest first
testing to make sure an asset is selected.</p>
<p>For example, let's assume you have the image chooser field saved
to the variable <code>$image_field</code>:</p>
<pre>
<code>#if (!$_PropertyTool.isNull($image_field.asset))
<img src="${image_field.asset.link}" alt="${image_field.asset.metadata.title}"/>
#end</code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-11T13:08:14Z2016-08-11T13:08:14ZGet path data from a page other than the calling page?<div><p>Ryan,<br>
I've tried using the .asset.path and it doesn't return
anything.</p>
<pre>
<code>#set ( $news_link = $single_news.asset.link )
<div class="news-block-body">
<a href="${news_link}" class="news-block-link">$headline</a>
</div></code>
</pre></div>voltmer1tag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-11T15:34:51Z2016-08-11T15:34:51ZGet path data from a page other than the calling page?<div><p>Hi,</p>
<p>As I mentioned previously, you will need to reference the actual
chooser field in order to use <code>.asset.link</code>. For
example, the code I provided earlier:</p>
<pre>
<code>## Reference the thumbnail-image chooser field
#set( $thumbnail_image = $single_news.getStructuredDataNode('thumbnail-image'))
...
## If there is a thumbnail chosen, output an IMG tag using the chosen asset's link.
#if (!$_PropertyTool.isNull($thumbnail_image.asset))
<img src="${thumbnail_image.asset.link}" alt="${thumbnail_image.asset.metadata.title}"/>
#end</code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-11T16:25:05Z2016-08-11T16:25:05ZGet path data from a page other than the calling page?<div><p>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.</p></div>voltmer1tag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-15T12:33:24Z2016-08-15T12:33:24ZGet path data from a page other than the calling page?<div><p>Ah, my apologies, I thought you needed the link for a chosen
asset. In that case, try dropping the <code>.asset</code> from the
snippet you provided earlier:</p>
<pre>
<code>#set ( $news_link = $single_news.link )
<div class="news-block-body">
<a href="${news_link}" class="news-block-link">${headline}</a>
</div></code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-15T16:17:41Z2016-08-15T16:17:41ZGet path data from a page other than the calling page?<div><p>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?</p>
<pre>
<code>#set( $thumbnail_image = $single_news.asset('thumbnail-image').link)</code>
</pre></div>voltmer1tag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-15T19:03:41Z2016-08-15T19:03:41ZGet path data from a page other than the calling page?<div><p>Sorry Ryan, I didn't see the earlier post (this works):</p>
<pre>
<code>#set( $thumbnail_image = $single_news.getStructuredDataNode('thumbnail-image'))
#if (!$_PropertyTool.isNull($thumbnail_image.asset))
<img src="${thumbnail_image.asset.link}" alt="${thumbnail_image.asset.metadata.title}"/></code>
</pre>
<p>Thanks again! I guess I don't understand when to use the
different methods.</p></div>voltmer1tag:help-archives.hannonhill.com,2010-02-09:Comment/404842512016-08-15T19:49:55Z2016-08-15T19:49:55ZGet path data from a page other than the calling page?<div><p>Not a problem at all. I am glad to hear the proposed snippet did
the trick.</p>
<p>When in doubt, you can always use the
<code>$_PropertyTool.outputProperties()</code> method on any object
to see what properties and methods are available to you.</p>
<p>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.</p>
<p>Have a great day!</p></div>Ryan Griffith