tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/11079-linkable-chooserCascade CMS: Discussion 2015-04-28T12:46:51Ztag:help-archives.hannonhill.com,2010-02-09:Comment/355303862014-12-12T19:23:05Z2014-12-12T19:23:05Zlinkable chooser<div><p>Hi Jim,</p>
<p>The previous post <a href=
"http://help.hannonhill.com/discussions/velocity-formats/11061-using-locatorquery-tool-api-in-velocity-cascade-7122">
Using Locator/Query Tool API in Velocity (Cascade 7.12.2)</a> is
directly related to your question. Assuming that you are working
with either a data definition block or a page associated with a
data definition, you first need to retrieve the node by calling
<code>getStructuredDataNode</code>. Once you have the node, then
you can call <code>getAsset</code> to get the asset chosen. With
the asset, then you can call <code>getType</code> to get the type
information.</p>
<p>Wing</p></div>Wing Ming Chantag:help-archives.hannonhill.com,2010-02-09:Comment/355303862014-12-12T19:58:44Z2014-12-12T19:58:44Zlinkable chooser<div><p>Jim,</p>
<p>After posting the previous reply, I suddenly realized that maybe
you are asking for something else. My previous reply assumed that
you are using the Locator tool to examine a block or a page. But if
you are working with a page region, then the XML of a block will
contain information of the following type:</p>
<pre>
<system-data-structure>
<quick-links-list-group>
<quick-links-text>Site Map</quick-links-text>
<linkable type="page">
</pre>
<p>The type information of a linkable is stored right in the
<code>type</code> attribute. I used the following code snippet to
display attribute values of all linkables in a block:</p>
<pre>
#set( $data = $_XPathTool.selectSingleNode( $contentRoot, "/system-data-structure" ) )
#set( $linkables = $_XPathTool.selectNodes( $data, "//linkable") )
#foreach( $linkable in $linkables )
#set( $attributes = $linkable.getAttributes() )
#set( $type = $attributes[ 0 ] )
$type.value<br />
#end
</pre>
<p>Wing</p></div>Wing Ming Chantag:help-archives.hannonhill.com,2010-02-09:Comment/355303862014-12-12T20:19:30Z2014-12-12T20:19:30Zlinkable chooser<div><p>A shorter version:</p>
<pre>
#foreach( $linkable in $linkables )
$linkable.getAttribute( 'type' ).value<br />
#end
</pre></div>Wing Ming Chantag:help-archives.hannonhill.com,2010-02-09:Comment/355303862014-12-12T20:21:25Z2014-12-12T20:21:25Zlinkable chooser<div><p>Thank you. I know it was something simple.</p>
<p>Much appreciated. You can close this discussion if you will.</p>
<p>Jim</p></div>steelejtag:help-archives.hannonhill.com,2010-02-09:Comment/355303862014-12-12T20:23:39Z2014-12-12T20:23:39Zlinkable chooser<div><p>Yes,<br>
This is more along the line of what I was after. I was looking to
use that “type” in an if statement—The velocity
equivalent of “If the type of $link = symlink.” –
I just don’t know the proper syntax for it.</p>
<p>Jim</p></div>steelejtag:help-archives.hannonhill.com,2010-02-09:Comment/355303862014-12-12T20:27:24Z2014-12-12T20:27:24Zlinkable chooser<div><p>Try something like <code>#if( $linkable.getAttribute( 'type'
).value.equals( 'page' ) )</code>.</p>
<p>Wing</p></div>Wing Ming Chan