Current time: 03-22-2010, 01:22 AM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Expander collapsed by default?
05-08-2009, 12:42 AM
Post: #1
Expander collapsed by default?
Hello guys.....

I was wondering if you could help me with a small matter.
(And I hope I have posted this in the correct section)

On my board I have given select members and groups permission to post HTML.
I would like to have a "Previews Box" that uses the expander.
However, I want it to be collapsed by default so that the content is hidden.
Is that possible?

Thanks heaps for your help!

Owen

PHP Code:
<table width="100%" cellpadding="6" cellspacing="1" border="0" class="tborder">
<
tbody>
            <
tr>
                <
td class="thead" colspan="2">
<
div class="expcolimage"><img src="{$theme['imgdir']}/collapse{$collapsedimg['newbox_e']}.gif" id="newbox_img" class="expander" alt="[-]" title="[-]" /></div>
              <
strong>Previews</strong>
                </
td>
            </
tr>
        </
tbody>
        <
tbody style="{$collapsed['newbox_e']}" id="newbox_e">  
            <
tr>
                <
td class="trow1">Test Content
                
</td>
            </
tr>
        </
tbody>
    </
table>
<
br /> 
Visit this user's website Find all posts by this user
Quote this message in a reply
05-08-2009, 10:44 AM (This post was last modified: 05-08-2009 10:44 AM by Tomm M.)
Post: #2
RE: Expander collapsed by default?
The way I'd do it is with cookies. MyBB responds to the 'collapsed' cookie. Doing this somewhere like global.php should auto-collapse the box.

Code:
my_setcookie("collapsed", "".$mybb->cookies['collapsed']."|newbox_img");

Where 'newbox_img' is the id of the div. Remember that it can get complicated - take into account that users might already have collapsed categories...

Tomm M
MyBB Developer » Marketing Designer & Systems Developer
Find all posts by this user
Quote this message in a reply
05-08-2009, 02:17 PM
Post: #3
RE: Expander collapsed by default?
Wow Tomm M!
Thank you for replying here and giving me a glimmer of hope!

I have a couple of questions:

1. Is 'newbox_img' a unique expression across the MyBB code?
I just copied the code from this post here: http://community.mybboard.net/thread-490...newbox_img
Basically, will setting a cookie for 'newbox' affect all the categories on my board?

2. Where would I add Tomm's code to global.php?
I had a look at global.php and I dont think it is a matter of just pasting it in anywhere I want.

Thanks for your help on this guys!

Owen
Visit this user's website Find all posts by this user
Quote this message in a reply
05-08-2009, 03:13 PM (This post was last modified: 05-08-2009 03:39 PM by Tomm M.)
Post: #4
RE: Expander collapsed by default?
Bah, I didn't mean to put newbox_img, I meant to put newbox_e. For example, if you add |newbox_e into the collapsed cookie, then it will automatically collapse the table with the tbody id of newbox_e. In your code, the following will "collapse"

Code:
<tbody style="{$collapsed['newbox_e']}" id="newbox_e">  
            <tr>
                <td class="trow1">Test Content
                </td>
            </tr>
        </tbody>

I made a plugin that will automatically collapse the quick-reply box, so it needs to do this. I'm not sure if there's an easy way to load one closed, I just imagined cookies are the easiest way...

PHP Code:
    $cookie $mybb->cookies['collapsed'];
        if(!
my_strpos($cookie,'quickreply')){
    
$expo explode("|",$cookie); for ($i=0$i<count($expo);$i++){ if($expo[$i] == "quickreply"){ $qurep 1; }}
    if(!
$qurep){ my_setcookie("collapsed""".$mybb->cookies['collapsed']."|quickreply"); }} 

That's the code I used (bit dirty, but hey), and I put it just before the global_end hook. It still works too... Smile

I would imagine that if you replaced references to "quickreply" and replace it with what tbody id it is you're trying to collapse, it would work for you too.

Tomm M
MyBB Developer » Marketing Designer & Systems Developer
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: