The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[HOW TO - vB4] Making Boxes Collapsible
Start: OK, here's a small guide how to make a boxes/layers collapsible. Let's say, you have a simple div-container you want to make collapsible. The css ids and classes assigned to the elements are completely arbitrary. Code:
<div id="test" class="anything"> <h2 class="blockhead"> <span>Collapse it!</span> </h2> <div class="blockrow"> <p>Let's add a button to collapse this box :-)</p> </div> </div> Step 1: Adding "collapse"-class to surrounding container Code:
<div id="test" class="anything collapse"> Step 2: Adding id to what we want to hide As a second step we have to add an unique id to the element that contains what we want to dissapear. Note: This element can be almost any html-tag that can be hidden (div, ul, ol, p, a - you get the idea). Note also: The element has to have an id that needs to be unique not only on the page, but on the whole site. So make sure you use some unique prefix, suffix or something like that (marked in blue). Code:
<div class="blockrow" id="cel_dummy"> Step 3: Adding collapse-button Inside the header add the code for the collapse-button. You'll have to adapt it according to the id you assigned in step 2 (adaptions needed marked in blue). Make sure the part you add inside the image name variable is not the exact same as the id you added to the container that you want to hide. If you add the exact same, the button will vanish under certain circumstances, too: Code:
<a class="collapse" id="collapse_cel_dummy" href="{vb:raw relpath}#top"><img src="{vb:stylevar imgdir_button}/collapse{vb:raw vbcollapse.collapseimg_cel_dummy_img}_40b.png" alt="{vb:rawphrase collapse_this_category}" /></a> Result: In the end, the code will look like that: Code:
<div id="test" class="block collapse"> <h2 class="blockhead"> <span>Collapse it!</span> <a class="collapse" id="collapse_cel_dummy" href="{vb:raw relpath}#top"><img src="{vb:stylevar imgdir_button}/collapse{vb:raw vbcollapse.collapseimg_cel_dummy_img}_40b.png" alt="{vb:rawphrase collapse_this_category}" /></a> </h2> <div class="blockrow" id="cel_dummy"> <p>Let's add a button to collapse this box :-)</p> </div> </div> Collapsed as default? Yes, but... There is a way default the box to be collapsed by default. But this it's quick and dirty, and really not recommended to use. Basically, you have to add display:none to the style of the collapsing container, like so: Code:
<div class="blockrow" id="cel_dummy" style="display: none;">
Collapse more than one box at a time? Yes, but... Now, functionally this is perfectly possible - just use the same id for every element you want to collapse together. But beware: for valid code you can't use duplicate ids on a page. So if you do that, your code will break xhtml validation! I hope this will be useful for some of you! -c Please note that this article has been written first for alpha 1 version and been updated for beta 3. There still may be changes until gold. For example the button used is clearly marked as beta (_40b in the file name). |
#22
|
||||
|
||||
No I didn't and I think I will have to. Since you was already playing with it - do you have any hints about which css style to use?
|
#23
|
||||
|
||||
What do you mean by css style? I already told you which selector/element to look for: a.collapse img
|
#24
|
||||
|
||||
I mean that I want to add style parameter to img element to override this one which is inside of a.collapse img and I was asking do you already know which css style exactly have to be overridden to keep it on it's place (like position, float) If you do not know - it's OK I will play with it. I just hoped that someone already know the answer and safe me some time
|
#25
|
||||
|
||||
As I said: I looked at it with firebug and the settings are just there to read. If you really want to work with vB4 styling, you really should make use of this. As a cleaner solution instead of inline styling I would recommend to give the img your own custom class and define that class in additional.css
|
#26
|
||||
|
||||
Thanks for help and sorry for all those questions - I was just lazy Your first information about css (a.collapse img) was enough - I just search whole vBulletin code for that and I found what I needed
Thanks once again :up: --------------- Added [DATE]1266506576[/DATE] at [TIME]1266506576[/TIME] --------------- Quote:
--------------- Added [DATE]1266507137[/DATE] at [TIME]1266507137[/TIME] --------------- Ok - I found solution anyway - I just went 1 level higher and play with style for a - seems working, but not tested in other browsers yet. --------------- Added [DATE]1266507539[/DATE] at [TIME]1266507539[/TIME] --------------- Working and tested. It is needed to ad in a with class collapse a style attribute with value position: static; float: none; So it goes: Code:
<a href="#top" class="collapse" style="position: static; float: none;" id=...
|
#27
|
||||
|
||||
Thanks, works like a charm, made a few changes to run it from a plugin, but still workds, lovely.
|
#28
|
|||
|
|||
Does this work in vBulletin admincp?
|
#29
|
||||
|
||||
Never tried, but I doubt it. This was reworked for vB4, and there have been no significant changes to the AdminCP, so maybe not. On a second thought, I am unable to remember having seen anything collapsible in the AdminCP before...
|
#30
|
||||
|
||||
Thanks!!
|
#31
|
||||
|
||||
Quote:
I was trying to make all my static-html cms widgets collapsible. The problem was that that template is for all static-html cms widgets, so when assign a unique id in HTML Code:
<a class="collapse" id="collapse_uniqueid"....
The solution was to make use of the widget's title as the unique id: HTML Code:
<a class="collapse" id="collapse_{vb:raw widget_title}"....
HTML Code:
<div class="cms_widget collapse"> <div class="block"> <div class="cms_widget_header"> <a class="collapse" id="collapse_{vb:raw widget_title}" style="position: static" href="{vb:raw relpath}#top"><img src="{vb:stylevar imgdir_button}/collapse_40b.png" alt="" border="0" /></a> <h3>{vb:raw widget_title}</h3> </div> <div class="cms_widget_content" id="{vb:raw widget_title}"> {vb:raw static_html} </div> </div> </div> And all that thanks to cellarius :up: |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|