Calling Child Slot from Raw slot (initslot macro)

okie for some weird reason I cannot seem to figure this out… Maybe the simple fact that it is midnight and that I am looking at code on a friday night is the real issue here.

Anyway I am building a snippet to generate a list of item for an accordion list. I am using the raw slot to do so so that I can count the items in the slot (ie nb of items in my accordion list) and also to find the first item and define ids in the code so that I can expand and collapse correctly. That’s all good and I have no issues there.

However the items in my accordion list have a slot so that I can add an image. I somehow can’t seem to just call this child slot… Could anyone help? I am sure someone must have done this before (I cannot believed I haven’t done this before myself!).

Anyway here is the code as it stands

#initslot("AccordionItem" "")
  #if($sys.currentslot.relresults.size() > 0)
	<div class="accordion" id="accordion2">
     #foreach( $relresult in $sys.currentslot.relresults )

##	This will insure that only the first item of the accordion is expandanded, all other items with be collapsed
	#if($velocityCount==1)##
	#set($collapseClass="accordion-body collapse in")##
	#else
	#set($collapseClass="accordion-body collapse")##
	#end##
		<div class="accordion-group">
    <div class="accordion-heading">
      <a href="#collapse$velocityCount" data-parent="#accordion2" data-toggle="collapse" class="accordion-toggle">
        <span class="number-collapse">$velocityCount</span>$relresult.getNode().getProperty('rx:displaytitle').String
      </a>
    </div>
	
    <div class="$collapseClass" id="collapse$velocityCount">
      <div class="accordion-inner">
      	<div class="preview">
	
		#slot_simple("Image")
	
      	<p class="lead">$relresult.getNode().getProperty('rx:cllout').String</p>
      	</div>
 </div>
  </div>
	</div>
	 #end
   #end
  #endslot("AccordionItem") 	

So I am struggling to call the Image slot (represented in the code with a simple slot) I have tried using another nested Raw slot or a node slot but without success.

Any help greatly appreciated.

Celine

Celine,

You may need to repost your code in a code sharing service like http://jsbin.com/ or http://gist.github.com/. The forum is really aggressive towards HTML in code segments.

Hi Riley,

Not to worry I figured this out… Thanks for your reply though :slight_smile:
Here is the code for reference if anyone needs to have a play with Accordion Lists.

#initslot("AccordionItem" "")
  #if($sys.currentslot.relresults.size() > 0)
	<div class="accordion" id="accordion2">
     #foreach( $relresult in $sys.currentslot.relresults )

##	This will insure that only the first item of the accordion is expandanded, all other items with be collapsed
	#if($velocityCount==1)##
	#set($collapseClass="accordion-body collapse in")##
	#else
	#set($collapseClass="accordion-body collapse")##
	#end##
		<div class="accordion-group">
    <div class="accordion-heading">
      <a href="#collapse$velocityCount" data-parent="#accordion2" data-toggle="collapse" class="accordion-toggle">
        <span class="number-collapse">$velocityCount</span>$relresult.getNode().getProperty('rx:displaytitle').String
      </a>
    </div>
	<div id='$contentid' class='defis'>
    <div class="$collapseClass" id="collapse$velocityCount">
      <div class="accordion-inner">
      	<div class="preview">

		 #set($cloneditem = $sys.assemblyItem.clone())
		  #set($slotname = "SlotImage")##
		 $cloneditem.setNode($relresult.getNode())##
		 #set($params.template = "SnMediumImage")## 
		 #set($list = $user.psoSlotTools.getSlotContents($cloneditem,$slotname,$params))##
		 #if($list.size() > 0)##
		 #foreach($item in $list)##
		 #set($img = $sys.asm.assemble($user.psoListTools.asList($item)))
		 $rx.doc.extractBody($img.get(0))##
		 #end
		 #end


      	<p class="lead">$relresult.getNode().getProperty('rx:cllout').String</p>
      	</div>
 </div>
  </div>
	</div>
	 #end
   #end
  #endslot("AccordionItem") 	
	</div>
	</div>
</div>

Celine, Thank you for sharing. Transferred your code over to a gist for reference