getting data from a block inside another block using the locator tool

Nando's Avatar

Nando

02 Jun, 2016 08:41 PM

#set ($navigation = $_.locateBlock(${navlocation}, $currentPageSiteName)) 
#set ($navtype = $navigation.getStructuredDataNode("navtype").textValue)## 
#if($navtype == "Links") 
#set ($links = $navigation.getStructuredDataNodes("link"))## 
#else 
#set ($navmirror = $navigation.getStructuredDataNode("navmirror"))## 
#end

$navmirror is the block inside the block and gives me: com.hannonhill.cascade.api.adapters.StructuredDataNodeAPIAdapter@277dd574 and the below does NOT work:

#set ($navmirrorpath = $navmirror.getStructuredDataNode("path").textValue)## 
#set ($navmirrorsite = $navmirror.getChild("site").textValue)##

all help is appreciated, thanks!

  1. 1 Posted by Ryan Griffith on 06 Jun, 2016 12:08 PM

    Ryan Griffith's Avatar

    Hi Nando,

    You will need to use the asset property in order to access the data for the chosen asset itself. For example:

    #set ($navmirror = $navigation.getStructuredDataNode("navmirror").asset)
    
    ...
    
    #if (!$_.PropertyTool.isNull($navmirror))
      #set ($navmirrorpath = $navmirror.getStructuredDataNode("path").textValue)## 
      #set ($navmirrorsite = $navmirror.getChild("site").textValue)
    #end
    

    Also, $navmirror.getChild("site").textValue will most likely not work because getChild is a method used for XML elements and not API objects. Instead, you would go with something like $navmirror.siteId or $navmirror.siteName.

    If you are unsure of what properties and methods are available for a given object, use the $_PropertyTool.outputProperties method.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by Nando on 07 Jun, 2016 12:52 PM

    Nando's Avatar

    Thanks Ryan! Wing helped me out as well on a 1 on 1 - you guys are awesome!

  3. Nando closed this discussion on 07 Jun, 2016 12:52 PM.

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

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM