{strip}
{if $gPigeonholes->mStructureId eq $subtree[ix].structure_id or $smarty.request.expand_all}
	{assign var=iname value=Expanded}
{else}
	{assign var=iname value=Collapsed}
{/if}

<div class="highlight">
	{if $edit}
		<div class="floaticon">
			{smartlink ititle="Edit Category" ibiticon="liberty/edit" ifile="edit_pigeonholes.php" structure_id=$subtree[ix].structure_id action=edit}
			{smartlink ititle="Remove Category" ibiticon="liberty/delete" ifile="edit_pigeonholes.php" structure_id=$subtree[ix].structure_id action=remove}
		</div>
	{/if}

	<a href="javascript:icntoggle('sid{$subtree[ix].structure_id}');">
		{biticon ipackage=liberty iname=$iname id=sid`$subtree[ix].structure_id`img"} {$subtree[ix].title}
	</a> &nbsp;

	<script type="text/javascript">
		setfoldericonstate('sid{$subtree[ix].structure_id}');
	</script>

	{foreach from=$pigeonList item=pigeonItem}
		{if $pigeonItem.structure_id eq $subtree[ix].structure_id}
			<small> {tr}{$pigeonItem.members_count} Item(s){/tr} </small>
		{/if}
	{/foreach}

	<noscript>
		<div style="padding-left:18px;" class="small"><a href="{$smarty.const.PIGEONHOLES_PKG_URL}{if $edit}edit_pigeonholes{else}index{/if}.php?structure_id={$subtree[ix].structure_id}">{tr}Expand{/tr}</a></div>
	</noscript>
</div>

{foreach from=$pigeonList item=pigeonItem}
	{if $pigeonItem.structure_id eq $subtree[ix].structure_id}
		<small>{$pigeonItem.data|escape}</small>

		{if $pigeonItem.members}
			<ul id="sid{$subtree[ix].structure_id}" style="display:{if $gPigeonholes->mStructureId eq $subtree[ix].structure_id or $smarty.request.expand_all}block{else}none{/if};" class="data">
				{foreach from=$pigeonItem.members item=pigeonMember}
					{if $gBitSystem->isFeatureActive( 'custom_member_sorting' )}
						<li>
							{if $edit && $gBitSystem->isFeatureActive( 'custom_member_sorting' )}
								{if $pigeonMember.pos ne 1}
									{smartlink ititle="Move item up" ibiticon="liberty/nav_up" expand_all=$smarty.request.expand_all ifile="edit_pigeonholes.php" action=move orientation=north structure_id=$pigeonItem.structure_id parent_id=$pigeonItem.content_id member_id=$pigeonMember.content_id}
								{else}
									{biticon ipackage="liberty" iname="spacer"}
								{/if}

								{if $pigeonMember.pos ne $pigeonItem.members_count}
									{smartlink ititle="Move item down" ibiticon="liberty/nav_down" expand_all=$smarty.request.expand_all ifile="edit_pigeonholes.php" action=move orientation=south structure_id=$pigeonItem.structure_id parent_id=$pigeonItem.content_id member_id=$pigeonMember.content_id}
								{else}
									{biticon ipackage="liberty" iname="spacer"}
								{/if}
							{/if}
							&nbsp; <a href="{$smarty.const.BIT_ROOT_URL}index.php?content_id={$pigeonMember.content_id}">{$pigeonMember.title}</a> &nbsp;
							{if $edit}
								{smartlink ititle="Remove Item" ibiticon="liberty/delete_small" expand_all=$smarty.request.expand_all ifile="edit_pigeonholes.php" action=demember structure_id=$pigeonItem.structure_id parent_id=$pigeonMember.content_id content_id=$pigeonItem.content_id}
							{/if}
						</li>
					{else}
						{assign var=ctg1 value=$pigeonMember.content_type_guid}

						{* close off the content type <ul> *}
						{if $ctg1 ne $ctg2 and $ctg2}
								</ul>
							</li>
						{/if}

						{* open the content type <ul> *}
						{if $ctg1 ne $ctg2}
							<li>{$gLibertySystem->mContentTypes.$ctg1.content_description}
								<ul>
						{/if}

						<li>
							<a href="{$smarty.const.BIT_ROOT_URL}index.php?content_id={$pigeonMember.content_id}">{$pigeonMember.title}</a>
							{if $edit}
								&nbsp; {smartlink ititle="Remove Item" ibiticon="liberty/delete_small" expand_all=$smarty.request.expand_all ifile="edit_pigeonholes.php" action=demember structure_id=$pigeonItem.structure_id parent_id=$pigeonMember.content_id content_id=$pigeonItem.content_id}
							{/if}
						</li>

						{assign var=ctg2 value=$pigeonMember.content_type_guid}
					{/if}
				{/foreach}

				{* close any open uls and lis *}
				{if !$gBitSystem->isFeatureActive( 'custom_member_sorting' )}
						</ul>
					</li>
				{/if}
			</ul>
		{/if}
	{/if}
{/foreach}
{/strip}
