View Single Post
  #32  
Old 03-18-2010, 07:29 PM
BRotondi BRotondi is offline
 
Join Date: Sep 2008
Location: Zurich
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by voglermc View Post
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:
  1. Collapse the users on posting #1 and #3
  2. load another thread
  3. 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?
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01831 seconds
  • Memory Usage 1,792KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete