parentlist parentid Conditional styling

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jim T4 Forum
    New Member
    • Mar 2008
    • 6
    • 3.6.x

    parentlist parentid Conditional styling

    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

    Code:
    <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.

    Code:
    <if condition="in_array('X', array($parentlist))">class="selected"</if>
    Please help!
  • Jim T4 Forum
    New Member
    • Mar 2008
    • 6
    • 3.6.x

    #2
    Update, this is kind working but only seems to read the first integer in the array
    Code:
    <if condition="in_array(14,array($foruminfo[parentlist]))">

    Comment

    • Jim T4 Forum
      New Member
      • Mar 2008
      • 6
      • 3.6.x

      #3
      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 Locationarse_templates

      Code:
      $parentarray= explode(',', $foruminfo[parentlist]);
      Then i can perform the array conditional inline using this new global variable

      Code:
      <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!

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...