I am trying compare the value of the content id of an items in a slot with a value that was created on a page that called this template. I want to then use the value of $parentInSubNav to see if I should display the slot later in the page.
My syntax to return the content id of the slot seems to be incorrect, any ideas on this would be appreciated.
Chris
## Find if calling page is in the subnav
#initslot("SLOTNAME" "")
#if($sys.currentslot.relresults.size() > 0)
#foreach( $relresult in $sys.currentslot.relresults )
#if($relresult.getProperty('sys_contentid').String == $navCallId)
#set($parentInSubNav = "y")
#end
#end
#end
I’m am setting $parentInSubNav in the bindings of a page that has this template in a slot. Herere is the code for that binding:
$sys.item.getProperty(‘sys_contentid’).String
I beleive as long as a snippet in that the page call does not have it’s own $parentInSubNav binding that value should be passed to the the snippet.
I am not setting $navCallId anywhere except in the if statement.
I do not receive any errors in the console. To test that the values were being collected I setup a couple of inserted them into p tags in the for statement:
Remember that the “results” in a slot are IPSAssemblyResult objects, and this interface doesn’t have a “getItem()” method. I suspect that you want the “getNode()” method (if your next step is to call getProperty())