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). |
#62
|
||||
|
||||
Then you need to find a way to add one. Likely in the template used by whatever you want to collapse.
|
#63
|
|||
|
|||
hmm im totatlly confused now.....
did try to collapse the wgo in forumhome template but failed big time... dunno what i did wrong... |
#64
|
||||
|
||||
I don't know either.
|
#65
|
|||
|
|||
Hi,
I was wondering if someone could explain how the collapsible box works when clicked to the box background it expands? Something like in slickdeals.net, when someone clicks the background, it expands. thanks |
#66
|
||||
|
||||
vB's collapse method does not allow for this, so this is not for this tutorial, really. You should open your own thread in an appropriate forum. Anyway, you'd have to fire the javascript on the click event of the background, not a link, generally speaking. But a tutorial on how to do that is really too much for this topic.
|
#67
|
|||
|
|||
thanks. I was wondering if there is a tutorial that shows how to store variables to DB during the post new thread session. And also how to retrieve those data from DB and render to a template.
|
#68
|
||||
|
||||
Sorry, bit that really has nothing to do with this tutorial at all. This is about collapsing boxes using the vB provided method, nothing else.
|
#69
|
|||
|
|||
Thanks for the guide. I thought I'll share something:
I had to find a way to collapse more than one element at the same time. Tried using the same ID for every element as you suggest but without luck - only the first one collapses. At the end I've added an empty collapse-triggering <A> tags for every additional element I need collapsed and chained their click events like this: <a class="collapse" id="collapse_elem1" href="{vb:raw relpath}#top" onClick="document.getElementById('collapse_elem2') .click();"><img ...... /></a> <a class="collapse" id="collapse_elem2" href="{vb:raw relpath}#top" onClick="document.getElementById('collapse_elem3') .click();"></a> <a class="collapse" id="collapse_elem3" href="{vb:raw relpath}#top"></a> Only the first <A> tag has the changing button image, the others are empty. This way I was able to collapse the elements with IDs "elem1", "elem2" and "elem3" simultaneously. Its not very elegant but does the trick |
#70
|
|||
|
|||
Nice workaround thanks for sharing!
|
#71
|
|||
|
|||
I tried to use this in a bbcode but its not converting {vb:raw relpath} to the correct path. it just leave it as %7bvb:raw relpath %7d any ideas on how to make it work in a bbcode?
|
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|