Retrieve Id's of Items in a Slot

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

Where are you setting $parentInSubNav and $navCallId ?

What’s the behavior? Are you getting any specific error message?

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:

		
#initslot("BGSU_Nav_Sub_Menu_Item" "")
#if($sys.currentslot.relresults.size() > 0)
#foreach( $relresult in $sys.currentslot.relresults )
<P>$navCallId </p>
<P> $relresult.item.getProperty('sys_contentid').String </p>
#if($relresult.item.getProperty('sys_contentid').String == $navCallId)
#set($parentInSubNav = "y")
#end
#end
#end

And when I do this the $navCellId seems to be outputed by the slot content id returns this “$relresult.item.getProperty(‘sys_contentid’).String”.

  • Chris

Chris,

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())

$relresults.node.getProperty(“rx:sys_contentid”).String

Try this and let us know if it works.

That worked perfectly.

Thanks for the help on this.