Quote:
Originally Posted by voglermc
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.
|
Why setting your own cookie? If you use a unique ID this will allready be done by default. At least it does with my vB4.0.2
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">
<a class="collapse" id="collapse_post_{vb:raw post.postcount}" 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>
<div class="userinfo" id="post_{vb:raw post.postcount}">
Now you will have a collapse/expand Button on the top right of every posting which will collapse the user informations. Now:
- Collapse the users on posting #1 and #3
- load another thread
- you will see that #1 and #3 are still collapsed, since their ID is the same in every Thread: post_1, post_3
[Of course it would be more intelligent to collapse something else, but this way all necessary code is in the range of 3 lines

]
--------------- Added 19 Mar 2010 at 00:13 ---------------
If you want to work via Plugin, you have to
- replace {vb:raw relpath} with $relpath etc.
- work via variables.
- hardencode the red part, until someone tells us, how to do it the right way (
) ($stylevar['imgdir_button'] and $vbcollapse['collapseimg_cel_dummy_img'] seem not to be accessible or are not set in certain hooks.)
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">';
An example to make replies collapsable: Create a plugin on hook
showthread_postbit_create with code
Code:
//B Replies collapsable
//first post?
if ($post['postcount'] == 1) {
$BThreadPage1 = true;
$BReplyFound = false;
$BThreadOwner = $post['userid'];
//page 1 of Thread?
} elseif ($BThreadPage1) {
//first reply allready found?
if ($BReplyFound) {
}
//is this the first reply?
elseif ($post['userid'] != $BThreadOwner) {
$BReplyFound = true;
//Debug echo "OPEN:" . $post['postcount'] . "|";
$postbits .='</ol>' .
'<div class="postdetails collapse">' .
' <a style="float:left; position:static;" class="collapse" id="collapse_collapsereplies" href="' . $relpath . '#top">Diskussion ein/ausblenden<img src="images/buttons/collapse_40b.png" alt="Diskussion ein/ausblenden" /></a>' .
' <div class="userinfo" id="collapsereplies">' .
' <ol id="posts" class="posts" start="' . $post['postcount'] . '">';
}
}
and a plugin on hook
showthread_complete with code
Code:
if ($BReplyFound) {
$postbits .='</ol></div></div><ol>';
}
--------------- Added 19 Mar 2010 at 00:27 ---------------
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">';
->
Hide Discussion ->
Show Discussion
--------------- 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?