Auto Index Content Containing a Slot

I am receiving a visual error when trying to auto index a content type that contains a manual slot within the snippet template. The slot appears to be aggregating all of the snippets for each loop of the auto index so that all snippets appear in all loops of the auto index.

Content Type Snippet (to be auto-indexed):


{html}
	{dl}
		{dt}#field("rx:displaytitle"){/dt}
    	{body}
    		#slot("erauContactExpert" "{dd}" "" "" "{/dd}" "")##
    	{/body}
	{/dl}
{/html}

Auto Index Tempalte:


#set($oldChar = "-1")##
		#initslot($slotname $params)##
		<ul>
		#foreach($result in $sys.currentslot.relresults)##
			#if($result.getNode().primaryNodeType.name == "rx:erauContact")##
				#set($currChar = $result.getNode().getProperty("rx:lastname").String.substring(0,1).toUpperCase())##
			#elseif($result.getNode().primaryNodeType.name == "rx:erauExpertCategory")##
				#set($currChar = $result.getNode().getProperty("rx:displaytitle").String)##
			#else##
				#set($currChar = $result.getNode().getProperty("rx:displaytitle").String.substring(0,1).toUpperCase())##
			#end##
			#if($currChar != $oldChar)#set($oldChar = $currChar){li}{a href="#$currChar"}$currChar{/a}{/li} #end##
		#end##
		{/ul}
		#set($oldChar = "-1")##
		#foreach($result in $sys.currentslot.relresults)##
			#if($result.getNode().primaryNodeType.name == "rx:erauContact")##
				#set($currChar = $result.getNode().getProperty("rx:lastname").String.substring(0,1).toUpperCase())##
			#elseif($result.getNode().primaryNodeType.name == "rx:erauExpertCategory")##
				#set($currChar = $result.getNode().getProperty("rx:displaytitle").String)##
			#else##
				#set($currChar = $result.getNode().getProperty("rx:displaytitle").String.substring(0,1).toUpperCase())##
			#end##
			#if($currChar != $oldChar)#set($oldChar = $currChar)##
				#slot($slotname "{h3}{a name='$currChar'}{/a}$currChar{/h3}{dl}" "" "" "{/dl}" "list='${currChar}%'&max_results=${max_results}&sitepath=${sitepath}&folderpath=${folderpath}")##
			#end
		#end##

Current Output (the problem, slots displayed with all names from all slots in the auto index):


<h1 class="">Accidents & Safety</h1>
<ul>
<li><a href="#Accident Analysis">Accident Analysis</a></li> 										<li><a href="#Aerospace Safety">Aerospace Safety</a></li> 											<li><a href="#Aircraft Accident Investigation">Aircraft Accident Investigation</a></li>
<li>etc...</li>
<h3><a name='Accident Analysis'></a>Accident Analysis</h3><dl>
    	<dd>
		<dl>name 1</dl>
                <dl>name 2</dl>
                <dl>name 1</dl>
                <dl>name 3</dl>
  	</dd>    	
<h3><a name='Aerospace Safety'></a>Aerospace Safety</h3><dl>
    	<dd>
		<dl>name 1</dl>
                <dl>name 2</dl>
                <dl>name 1</dl>
                <dl>name 3</dl>
  	</dd>
<h3><a name='Aircraft Accident Investigation'></a>Aircraft Accident Investigation</h3><dl>
    	<dd>
		<dl>name 1</dl>
                <dl>name 2</dl>
                <dl>name 1</dl>
                <dl>name 3</dl>
  	</dd>  

Expected Output (slots only showing the names contained in the manual slot):


<h1 class="">Accidents & Safety</h1>
<ul>
<li><a href="#Accident Analysis">Accident Analysis</a></li> 										<li><a href="#Aerospace Safety">Aerospace Safety</a></li> 											<li><a href="#Aircraft Accident Investigation">Aircraft Accident Investigation</a></li>
<li>etc...</li>
<h3><a name='Accident Analysis'></a>Accident Analysis</h3><dl>
    	<dd>
		<dl>name 1</dl>
  	</dd>    	
<h3><a name='Aerospace Safety'></a>Aerospace Safety</h3><dl>
    	<dd>
                <dl>name 2</dl>
                <dl>name 3</dl>
  	</dd>
<h3><a name='Aircraft Accident Investigation'></a>Aircraft Accident Investigation</h3><dl>
    	<dd>
		<dl>name 1</dl>
                <dl>name 2</dl>
  	</dd>

This is a case of $sys.currentslot getting overwritten combined with malformed html in your snippet.

Your Content Type Snippet should look like this (notice that all the code specific to the snippit is inside the body tags):

{html}
    	{body}
	{dl}
		{dt}#field("rx:displaytitle"){/dt}
    		{dd}#slot_simple("erauContactExpert"){/dd}
	{/dl}
    	{/body}
{/html}

Your calling code should look like this (i’ve highlighted the changes in bold):

#set($oldChar = "-1")##
#initslot($slotname [b]"max_results=${max_results}&sitepath=${sitepath}&folderpath=${folderpath}"[/b])##
[b]{ul}[/b]
#foreach($result in $sys.currentslot.relresults)##
	#if($result.getNode().primaryNodeType.name == "rx:erauContact")##
		#set($currChar = $result.getNode().getProperty("rx:lastname").String.substring(0,1).toUpperCase())##
	#elseif($result.getNode().primaryNodeType.name == "rx:erauExpertCategory")##
		#set($currChar = $result.getNode().getProperty("rx:displaytitle").String)##
	#else##
		#set($currChar = $result.getNode().getProperty("rx:displaytitle").String.substring(0,1).toUpperCase())##
	#end##
	#if($currChar != $oldChar)#set($oldChar = $currChar){li}{a href="#$currChar"}$currChar{/a}{/li} #end##
#end##
{/ul}
#set($oldChar = "-1")##
#foreach($result in $sys.currentslot.relresults)##
	#if($result.getNode().primaryNodeType.name == "rx:erauContact")##
		#set($currChar = $result.getNode().getProperty("rx:lastname").String.substring(0,1).toUpperCase())##
	#elseif($result.getNode().primaryNodeType.name == "rx:erauExpertCategory")##
		#set($currChar = $result.getNode().getProperty("rx:displaytitle").String)##
	#else##
		#set($currChar = $result.getNode().getProperty("rx:displaytitle").String.substring(0,1).toUpperCase())##
	#end##
	#if($currChar != $oldChar)#set($oldChar = $currChar)##
		[b]{h3}{a name='$currChar'}{/a}$currChar{/h3}[/b]
		[b]$rx.doc.extractBody($result)[/b]
	#end
#end##
[b]#endslot($slotname)##[/b]

I don’t understand why you’d want to pass all that info to the sub-slot, but I figure you have your reasons… the list param in your initial code isn’t passable in this new context so i left it out. You will have to come up with another way to reconstruct the value within the snippit template if it’s absolutely critical.

Thanks Sam, the code you provided worked without any modification. I appreciate your help!


#if($currChar != $oldChar)#set($oldChar = $currChar)##
	{h3}{a name='$currChar'}{/a}$currChar{/h3}{dl}$rx.doc.extractBody($result){/dl}
			#end

I am running Rx 6.5.2 at the moment and don’t even see #endslot as a macro option.

I understand this process seems a little non-standard but I wanted to give the owner of the erauExpertCategory Content Type the ability to create/edit their own lists of contacts without needing to modify the erauContact Content Type since it is owned by other Communities. So the result is what you see here, auto-indexing two content types (erauContact and erauExpertCategory) all to ensure content reuse and community separation. It might make more sense to see this solution in action (http://news.erau.edu/media-kit/experts/index.html), this site will be going live soon so parts of it are not complete.

The next modification to this process will likely be alphabetical ordering of the names returned in the $result.

I run 6.5.2 myself most days. :slight_smile: it’s in there. trust me