jim doodle
03-31-2008, 02:44 AM
Hi there, i have a tabulated css layout that needs a class assigning it as selected, I want to define this selected class by the parentID, or of the parentList contains X
<if condition="$foruminfo[parentlist] == X">class="selected"</if>
However since this checks for a match rather than a contains i am stuck as i am not sure how to check with an array i did have something liek this but to no avail.
<if condition="in_array('X', array($parentlist))">class="selected"</if>
update this code nearly works, but only seems to read the first integer in the array?!? Any help ?
<if condition="in_array(14,array($foruminfo[parentlist]))">
--------------- Added 1206992160 at 1206992160 ---------------
To answer my own question, $parentlist is a string not an array, so i need to explode this in to an array. However i can't do this inline as explode is not a valid php function for vb, instead i setup plugin.
plug-in > Hook Location:parse_templates
$parentarray= explode(',', $foruminfo[parentlist]);
Then i can perform the array conditional inline using this new global variable
<if condition="in_array(14, $parentarray)">class="selected"</if>
This doesn't actually evaluate in the template, but continue anyway, and all is well.
TA DA! Well i'm impressed anyway!:)
<if condition="$foruminfo[parentlist] == X">class="selected"</if>
However since this checks for a match rather than a contains i am stuck as i am not sure how to check with an array i did have something liek this but to no avail.
<if condition="in_array('X', array($parentlist))">class="selected"</if>
update this code nearly works, but only seems to read the first integer in the array?!? Any help ?
<if condition="in_array(14,array($foruminfo[parentlist]))">
--------------- Added 1206992160 at 1206992160 ---------------
To answer my own question, $parentlist is a string not an array, so i need to explode this in to an array. However i can't do this inline as explode is not a valid php function for vb, instead i setup plugin.
plug-in > Hook Location:parse_templates
$parentarray= explode(',', $foruminfo[parentlist]);
Then i can perform the array conditional inline using this new global variable
<if condition="in_array(14, $parentarray)">class="selected"</if>
This doesn't actually evaluate in the template, but continue anyway, and all is well.
TA DA! Well i'm impressed anyway!:)