Author Topic

Clemens T

Thursday 08 December 2005 4:56:54 pm

Comment44863

Ok, this code took me about 3 hours.. and lots of thinking.. because I'm not very familiar with the section, section-else code etc...(cause I started from 3.6) I've checked this code in 3.7, should work with 3.5 though.

Here is the solution:

{let node=fetch('content','node', hash('node_id','63'))}
{let nodetest=$node}
	{*loop as much as the depth of the current item of the tree, otherwise parent could be NULL*}
	{section loop=$node.depth}
		{switch match=$nodetest.object.class_name}
		{case match="Geopositionnement"}
			Geopositionnement: {$nodetest.object.class_name},{$nodetest.node_id}<br/>
			{*if the current class_name=Geopositionnement*}
			{set $nodetest=$nodetest.parent}
		{/case}
		{case}
			Not a Geopositionnement: {$nodetest.object.class_name},{$nodetest.node_id}<br/>
			{*the default case, if the current class_name != Geopositionnement*}
		{/case}
		{/switch}
	{/section}
{* at this point, $nodetest is filled with the last Geopositionnement in the tree, exactly the same as your code does (correct me if I'm wrong) *}
{/let}
{/let}

Greets and all the best,
Clemens
ps: please mark your topic title 'solved' if it's solved...