How do I configure this so that it's automatically collapsed when a guest enters, as opposed to being opened by default?
I think this does what you want.
In index.template.php -
Find this:
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var current_header = ', empty($options['collapse_header']) ? 'false' : 'true', ';
function shrinkHeader(mode)
{';
// Guests don't have theme options!!
if ($context['user']['is_guest'])
echo '
document.cookie = "upshrink=" + (mode ? 1 : 0);';
else
echo '
smf_setThemeOption("collapse_header", mode ? 1 : 0, null, "', $context['session_id'], '");';
echo '
document.getElementById("upshrink").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");
document.getElementById("upshrinkHeader").style.display = mode ? "none" : "";
document.getElementById("upshrinkHeader2").style.display = mode ? "none" : "";
current_header = mode;
}
// ]]></script>';
Change it to this:
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var current_header = ', empty($options['collapse_header']) ? 'false' : 'true', ';
function shrinkHeader(mode)
{';
// Guests don't have theme options!!
if ($context['user']['is_guest'])
// echo '
// document.cookie = "upshrink=" + (mode ? 1 : 0);';
// else
echo '
smf_setThemeOption("collapse_header", mode ? 1 : 0, null, "', $context['session_id'], '");';
echo '
document.getElementById("upshrink").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");
document.getElementById("upshrinkHeader").style.display = mode ? "none" : "";
document.getElementById("upshrinkHeader2").style.display = mode ? "none" : "";
current_header = mode;
}
// ]]></script>';
Incredible, worked like a charm. O:)
Apparently it didn't work :( :'( I thought it did but it was only caching my previous suggestion.
Once again, I want that table pre-collapsed when a visitor comes in - I don't want it expanded at first visit.
Try this
change
var current_header = ', empty($options['collapse_header']) ? 'false' : 'true', ';
to
var current_header = ', empty($options['collapse_header']) ? 'true' : 'flase', ';
Lainaus käyttäjältä: MrGrumpy - toukokuu 25, 2011, 12:39:00 IP
Try this
change
var current_header = ', empty($options['collapse_header']) ? 'false' : 'true', ';
to
var current_header = ', empty($options['collapse_header']) ? 'true' : 'flase', ';
First thing I tried, didn't work.
No clue why it didn't work. Worked every time last night, and I did it and undid it several times, so it's not a caching problem. Doesn't work at all today. WTF?
Ok, try this -
In index.template.php
Find this:
// We'll have to use the cookie to remember the header...
if ($context['user']['is_guest'])
{
$options['collapse_header'] = !empty($_COOKIE['upshrink']);
$options['collapse_header_ic'] = !empty($_COOKIE['upshrinkIC']);
}
// Output any remaining HTML headers. (from mods, maybe?)
echo $context['html_headers'], '
Change it to this:
// We'll have to use the cookie to remember the header...
if ($context['user']['is_guest'])
{
$options['collapse_header'] = !empty($_COOKIE['upshrink']);
$options['collapse_header_ic'] = !empty($_COOKIE['upshrinkIC']);
}
/// Collapse header default for guests
if ($context['user']['is_guest'])
$options['collapse_header'] = '1';
// Output any remaining HTML headers. (from mods, maybe?)
echo $context['html_headers'], '
Works tonight - no guarantee it'll work tomorrow.
Not a caching problem - it's a cookie thing. Apparently the board drops a cookie on a guest if they collapse the header, and that's why the fix appears to work. I believe the new fix will work regardless, but kick it around and see what it does.
LainaaWorks tonight - no guarantee it'll work tomorrow.
lol, it worked.