[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"> 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"> 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). |
thanks
|
Thanks,
if the user has JavaScript disabled, we can add : HTML Code:
|
Do I have to use "class="collapse"" in my collapse/expand link?
Because when I do, it puts the link at the very top right of the post's and no matter where I move the link code in the template, it will always place it at the top right (near the inline moderation radio button area). And if I choose not to use class "collapse" then when I click the link it no longer collapse's/expand's but instead jumps to the top of the page. |
Yes, you need to use the collapse class. If you want to change locations etc., override it's settings or add an own class that overrides them.
|
Whenever I change the class for a custom one I made the expand/collapse function no longer works. See my thread here:
https://vborg.vbsupport.ru/showthread.php?t=231538 |
You can assign more than one class to an element, like so: class="collapse yourclass".
|
Here is what Im working with:
Quote:
|
Having a second class works for me. Just tested once again using Firebug to add a second class to a standard collapsible box in vB4. Having "collapse test" on the a-tag around the collapse-button in posting pormissions box on showthread leaves functionality intact.
|
Awesome! How would I go about adding a border and changing the background color? Also, I noticed the collapse button isn't centered vertically, but instead it touches the bottom. How do I adjust this?
|
Quote:
To change positioning, you need to add an additional class as described in the postings right before yours to override the settings in collapse class. |
Quote:
Thanks for the article. |
So tell me what is wrong with my code ?
Quote:
|
Example given in article forces the way how it will be displayed. I want to have collapsable blocks but without blockhead and having collapse image in place where I put it. Now it is not possible. Even if I remove classes blockhead and blockrow my collapse image is not in place where I put it but goes to right side and is inside of collapsable block (what also makes me impossible to have it collapsed by default).
So - what changes I need, to have my collapse image in place where it is set? - not moved to other one like it is now. |
You need to find out what css definitions make it go to the right. Use a tool like firebug for that. IIRC it is the collapsible-class that forces it to the right. Since you need that class for the collapse javascript to work, you'll need to override it.
|
Quote:
|
Did you try looking at it using firebug? I can manipulate positioning by modifying a.collapse img, and the javascript does not mess with positioning as far as I can tell.
|
I'm trying to collapse my header for smaller monitors and have a cookie set so it remembers the open or closed state like VB does in its collapse buttons. It doesn't seem to work. Can anyone help me get this so it remembers the cookie?
Code:
<div id="vb4_container"> Code:
|
I would think that your code collides with vB's. If you're setting your own cookie anyway, just don't use vB's collapsing method at all. That'll be probably much easier than getting this to work together.
|
I sure could use your help!
|
Quote:
|
What do you mean by css style? I already told you which selector/element to look for: a.collapse img
|
Quote:
|
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 :)
|
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=... |
Thanks, works like a charm, made a few changes to run it from a plugin, but still workds, lovely.
|
Does this work in vBulletin admincp?
|
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...
|
Thanks!!
|
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"> And all that thanks to cellarius :up: |
Quote:
And a big thanks for this tutorial!! Bruno --------------- Added 18 Mar 2010 at 21:50 --------------- Perhaps this little example is a good starting point, also to see how IDs and remembering the state in the cookie works: Open postbit_legacy and add the red code: Code:
<div class="postdetails collapse">
--------------- Added 19 Mar 2010 at 00:13 --------------- If you want to work via Plugin, you have to
Code:
$exampleVar = '<div class="postdetails collapse"><a class="collapse" id="collapse_collapsereplies" href="' . $relpath . '#top"><img src="' . 'images/buttons' . '/collapse' . '' . '_40b.png" alt="' . $vbphrase['collapse_this_category'] . '" /></a><div class="userinfo" id="collapsereplies">'; Code:
//B Replies collapsable Code:
if ($BReplyFound) { One thing I don't know but isn't important yet: When using a text instead of the icon only. How can I change the text so it says whether the box is collapsed or not? Code:
<a class="collapse" id="collapse_collapsereplies" href="' . $relpath . '#top">Hide/Show Discussion<img src="images/buttons/collapse_40b.png" alt="Discussion on/off" /></a><div class="userinfo" id="collapsereplies">'; --------------- Added 19 Mar 2010 at 00:58 --------------- Question: One I could use right now: Is there a way to collapse all User Infos at once, so there isn't even a white space? |
Quote:
Forumhome template, find: HTML Code:
<!-- what's going on box --> HTML Code:
<!-- what's going on box --> HTML Code:
{vb:raw template_hook.forumhome_wgo_pos5} HTML Code:
{vb:raw template_hook.forumhome_wgo_pos5} |
1 Attachment(s)
Modified also this, works fine :). Thanks!
But what I want, is to collapse multiple containers at once, e.g. the userinfo (see attachment 1 -> 2 How could this be done? (I want to get attachment 3 at a final stage, but first 2 to understand the basics. 3 needs more changes) Thanks! Bruno |
Oh... I see what you want, but I guess that you really want is more fun!!! :)
I said that because I think that sometimes, in terms of efficiency simple ways are better. So maybe at this point I would start considering to use the postbit look instead of the legacy_postbit, or a hack that gives your users a chance to switch between them. After all, the main purpose of postbit is precisely to give more horizontal space to that area, and there it is. |
Thanks for your thoughts, but the reason is, to really hide user informations.
I'm trying different things to make a wiki obsolete. Or better said: To have wiki articles inside the forum, in the same data tables. It was easy to create a wiki user (everyone can edit it and see his history, including who changed what) and make discussions disappear (Thanks to this thread: Collapse the postings after the first). Next step: Forget about the user, as common in wikis. Implementation: Isn't it possible with vBs own scripts: Read value from Cookie and set/unset .postbitlegacy .userinfo {display="none";}? |
Brilliant, does exactly as described, perfect, thank you.
|
Been playing around with this and am stuck. What i want to do is have the userinfo in postbit_legacy collapsible by userid rather than which post in a thread (like described in this post). So I could hide a certain user's info and it would stick throughout the forum regardless of where they post.
That make sense? |
I realized something similar for "collapse all user info and other details", could surely be changed to "collapse info of users by id".
Look at ProjectBay.net > Thread and press the http://projectbay.net/images/details.png-Button on the right (FireFox: Alt-Shif-i). Interesting for you? Bruno |
Not quite.Thank you though.
|
So what you want is something similar to the "Invisible User", which seems, as it has been sent to "ignore user" from every one?
|
All times are GMT. The time now is 10:38 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 | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|