first: i try to code a while loop in 3.5 because of the php server version, and because I try to make an extension that could be used by each ez versions...
2ndly:
I spend more than 3 days on this loop.
no more results....
I dont see anything I could use in your reply (sory).
you say to use loop=
but loop=what?
do you have more informations? thx in advance.
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...
Ok, this code does exactly the opposite of what you want... that's the only thing you got to fix..now it goes up in the tree, as long as the parent = Geopositionnement, you need to make it so that it goes up the tree until it reaches the Geopositionnement, well at least.. does not do another replace of the $nodetest by it's parent, I'd say.. use a $match variable, so you can control it if you already found a match.
{switch match=$object.class_name}
{case match="Spot"}
{let node=fetch('content','node', hash('node_id',$main_node_id))}
{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="Geoposition"}
{*if the current class_name=Geoposition*}
{/case}
{case}
{set nodetest=$nodetest.parent}
{*the default case, if the current class_name != Geoposition*}
{/case}
{/switch}
{* 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) *}
You must be logged in to post messages in this topic!