Author Topic

Yngve Bergheim

Friday 14 October 2005 2:17:21 am

Comment20101

Wow. It works!

This is how you can make dynamic right column;

1. Make a sidebar class (copy the folder class)
2. Put the sidebar code below in your right column template file (to try it quick and dirty, add it in design/standard/templates/toolbar/full/node_list.tpl
3. The sidebar-folder will display all the children nodes in the right column.
4. Modify your folder.tpl so it does not show sidebar classes: Add the following code in “set list_items=fetch_alias(…”

class_filter_type, exclude,
class_filter_array, array( 'sidebar' ),

Sidebar code:

{def $thisNode=$node}
{def $thisParent=$thisNode.node_id}
{def $isSidebar=false() }
{def $i=0 }

{* Loop untill we find a sidebar *}
{while ne($isSidebar,true() )  }

	{* Make sure we don't walk up the node tree more then 4 times *}
	{if ne($i,4)}	
		
		{* Fetch current node and make sure sidebar is a children *}	
		{let Children=fetch('content', 'list', 
					hash('parent_node_id', $thisParent,
					'depth', 1,
					class_filter_type, include,
					class_filter_array, array( 'sidebar' ),
				))}
				
			{* If this node got a sidebar, print it *}
			{if eq($:Children.0.name,'Sidebar') }
				{section var=childrenList loop=$Children}
					{node_view_gui view=full content_node=$childrenList}
					{set $isSidebar=true() }
			    {/section}
			{else}
			    {set $thisParent=$thisNode.node_id}
			    {* If this node not is the root node, get parent node *}
			    {if ne($thisNode.node_id,1) }
   			    	{set $thisNode=fetch('content','node',hash('node_id',$thisNode.parent_node_id))}
   			    {else}
   			    	{set $isSidebar=true()}
   			    {/if}
		    {/if}
		{/let}
		
		{set i=$i|inc}
	{else}
		{set $isSidebar=true()}
	{/if}
{/while}			
		
{undef $thisNode}
{undef $isSidebar}	
{undef $thisParent}