MyBB Community Forums

Full Version: Expander
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(2010-12-08, 11:05 PM)- G33K - Wrote: [ -> ]Assuming you're using templates:

The image:
<img src="{$theme['imgdir']}/{$expcolimage}" id="UNIQUEID_img" class="expander" alt="" title="" />

The div/table to hide/show:
<div id="UNIQUEID_e">

Notes:
- The image must have the expander class
- UNIQUEID must be completely unique and not used elsewhere on the page
- $expcolimage must be defined in your code based on whether its collapsed or expanded, otherwise it will not work or will show incorrect image for the collapse/expand. If you can't do that then just use collapse.gif but keep in mind that the image might become incorrect if page is refreshed.


How would one go about defining in your code to use expcolimage?

I have tried both methods in this thread has anyone ever successfully made a custom box that worked and saved the collapse?

I have tried both methods in this thread has anyone ever successfully made a custom box that worked and saved the collapse?
(2011-01-27, 04:02 AM)steven1022 Wrote: [ -> ]
(2010-12-08, 11:05 PM)- G33K - Wrote: [ -> ]Assuming you're using templates:

The image:
<img src="{$theme['imgdir']}/{$expcolimage}" id="UNIQUEID_img" class="expander" alt="" title="" />

The div/table to hide/show:
<div id="UNIQUEID_e">

Notes:
- The image must have the expander class
- UNIQUEID must be completely unique and not used elsewhere on the page
- $expcolimage must be defined in your code based on whether its collapsed or expanded, otherwise it will not work or will show incorrect image for the collapse/expand. If you can't do that then just use collapse.gif but keep in mind that the image might become incorrect if page is refreshed.


How would one go about defining in your code to use expcolimage?

I have tried both methods in this thread has anyone ever successfully made a custom box that worked and saved the collapse?

I have tried both methods in this thread has anyone ever successfully made a custom box that worked and saved the collapse?

It does work if used correctly. Maybe you can post your code here (or in PM) so we can look at how you're using it and give you pointers.
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<thead>
<tr>
<td class="thead">
<div class="expcolimage"><img src="{$theme['imgdir']}/collapse{$collapsedimg['chat']}.gif" id="chat_img" class="expander" alt="[-]" title="[-]" /></div>
<div><strong>{$lang->sf_sb_shoutbox}</strong> (<a href="index.php?action=full_shoutbox">{$lang->sf_sb_fullsbox}</a>)<br /></div>
</td>
</tr>
</thead>
<tbody style="{$collapsed['chat_e']}" id="chat_e">
<tr>
 <td class="trow2" align="center"><form onSubmit="ShoutBox.postShout(); $('shout_data').value = ''; return false;">{$lang->sf_sb_shout} <input type="text" id="shout_data" size="128" /> - <input type="submit" value="{$lang->sf_sb_shoutnow}" id="shouting-status" /></form></td>
</tr>
<tr>
 <td class="trow1"><div id="shoutbox_data" style="height: {$mybb->settings[sf_sb_height]}px; overflow: auto;">{$lang->sf_sb_loading}</div></td>
</tr>
</tbody>
</table>

<br />

<script>
ShoutBox.refreshInterval = {$mybb->settings[sf_sb_refresh_interval]};
ShoutBox.MaxEntries = {$mybb->settings[sf_sb_shouts_main]};
ShoutBox.lang = ['{$lang->sf_sb_posting}', '{$lang->sf_sb_shoutnow}', '{$lang->sf_sb_loading}', '{$lang->sf_sb_flood_check}', "{$lang->sf_sb_no_perform}"];
{$extra_js}
Event.observe(window, 'load', ShoutBox.showShouts); 
</script>

www.impaledbeast.com/forums

account login
test <-user
testtest <-password

It works and is functional but does NOT save state so on reload it is ALWAYS expanded.
You need to add $collapsed to the global scope in the function that is evaluating that shoutbox template.

What I mean is you need to add $collapsed to the list of global variables in the shoutcast's function.
(2011-01-31, 11:27 AM)- G33K - Wrote: [ -> ]You need to add $collapsed to the global scope in the function that is evaluating that shoutbox template.

What I mean is you need to add $collapsed to the list of global variables in the shoutcast's function.

Okay I sort of understand what your saying but my template uses the code I just posted for the boardstats but instead of chat it has boardstats in there, and it works fine, example below.

{$collapsed['boardstats_e']}

So shouldnt that mean when using chat it would work fine?

And if not where do I add the variable $collapsed to, which file, and how do I define it? ----> What i think you are saying is the boardstats functions already have $collapsed being called, but the shoutbox templates do not, so therefore I would need to find the shoutboxes functions and add the function $collapsed to them just by itself? I dont define it as anything?
If you're using boardstats_e then your shoutbox expand/collapse will end up being the same as that of the boardstats.

Can you tell me what plugin you're using for your shoutbox, it'll be easier for me to look at it and tell you exactly what to change where.

FYI: $collapsed is an array that holds the display show or hide style depending on whether the div was expanded or collapsed, the value of which is read from the cookie that is set when you expand/collapse. This is all done in the global.php file and as such you can use $collapsed throughout the board, however, if you're using it inside a function (as is the case with plugins) then you need to define it in the global scope to be able to use it.
OHHHH I got it, I understand now. (Basically in non php peoples terms for people who encounter this problem in the future, read below)

A plugin will call to the functions it uses from global in it somewhere. It will look similar to this (my situation)

function sb_output_control($page_data)
{
	global $mybb, $templates, $sf_shoutbox, $lang, $theme;

All you need to do is add the $collapsed function so it actually interacts like its supposed to like so:
function sb_output_control($page_data)
{
	global $mybb, $templates, $sf_shoutbox, $lang, $theme, $collapsed;


Thanks a lot G33K you just pushed me to understand the way MyBB is coded a lot more than I did, I assumed that the plugins just picked up everything in global, similar to WordPress, but anywho....Thanks again.
I'm trying to find my mistake, but I cannot ;/ I have same problem as steven1022 - div is always expanded after reloading.

My forum url is http://j-games.pl, and I want to permanent close the slider on the top.

This is php code of this slider from header templates:
<br><div style="float: right;"><img src="{$theme['imgdir']}/collapse{$collapsedimg['overview']}.gif" id="trololo_img" class="expander" alt="" title="" /></div><br />
<center><div id="trololo_e"><div class="skin-slidedeck">{$recenzje}</div></div>
</center>
<script type="text/javascript">

			jQuery('.slidedeck').slidedeck({
 autoPlay: true,
                cycle: true, 
         });

		</script>
Pages: 1 2