vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Design and Graphics Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=168)
-   -   parentlist array Conditional styling (https://vborg.vbsupport.ru/showthread.php?t=174650)

jim doodle 03-31-2008 02:44 AM

parentlist array 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>
update this code nearly works, but only seems to read the first integer in the array?!? Any help ?

Code:

<if condition="in_array(14,array($foruminfo[parentlist]))">
--------------- Added [DATE]1206992160[/DATE] at [TIME]1206992160[/TIME] ---------------

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

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


All times are GMT. The time now is 08:36 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01293 seconds
  • Memory Usage 1,709KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete