The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Set modules to be expanded to collapsed dependant on some condition
Hi
hopefully the title explains this but anyway: What I want to do is set things so that some of the modules that make up the vb pages are either expanded or collapsed dependant on some condition in the template I am using code based on this generic stuff for expandable sections Code:
<tbody> <tr> <td class="thead"> <a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('give_a_table_id')"><img id="collapseimg_give_a_table_id" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_give_a_table_id].gif" alt="" border="0" /></a> any information this is the header </td> </tr> </tbody> <tbody id="collapseobj_give_a_table_id" style="$vbcollapse[collapseobj_give_a_table_id]"> <tr> <td class="alt2">any information inside the module</td> </tr> </tbody> Anyway what I want to do in my templates is something like <if condition = something or other> display module expanded when page is generated <else> display module collapsed when page is generated Obviously the user can still collapse/expand manually using the little chevrons How do I go about doing that? cheers Rich |
#2
|
|||
|
|||
The blocks are expanded and collapsed by setting the style to "display:none" or not. The state for each block for a user is saved in a cookie that has a list of collapsed blocks. If you look in global.php and search for "read the list of collapsed menus" (around line 57) you can see where it gets the cookie info and sets the $vbcollapse[] to "display:none". So you could probably override that in your template by not using $vbcollapse['collapseobj_whatever'] as the style, or unset()ing it before the page is generated. (same goes for collapseimg_ and collapsecel_ of course. I think collapseimg_ is for the button image, I don't know what collapsecel_ is offhand). But, since that doesn't change the cookie, it would go back to the saved state if the override condition went away (which maybe is what you want, I don't know).
After the page is loaded the blocks are toggled by javascript setting the display property. I think you maybe could set the block to open by iserting a call to toggle_collapse('tableid', 'open') like Code:
<if condition="something"> <script type="text/javascript">toggle_collapse('tableid', 'open')</script> </if> somewhere in the template for that page (it might have to be in a function that gets run after the page is completely loaded, I don't know). I haven't tried this so I don't know if that will end up changing the cookie or not. I suppose another option if you want to change the saved cookie value in the php script would be to alter the string to take out your tableid and then set a new cookie value (can't remember what that call is offhand). |
#3
|
||||
|
||||
Thanks for that info kh99 (or Bob isn't it if i remember right)
OK problem solved What I did is set the $vbcollapse[] in my php like below, immediately before eval(ing) the modules template if (whatever condition) { $vbcollapse['collapseobj_name_of_this_module'] = ""; // this displays the module expanded } else { $vbcollapse['collapseobj_name_of_this_module'] = "display:none;"; // this displays the module collapsed } and it does exactly what I wanted, automagically overriding the users preference dependant on the condition being true or not, but not changing the cookie settings either way. Cheers m8 Rich |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|