Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Aiheen aloitti: Biology Forums - toukokuu 24, 2011, 10:29:53 IP

Otsikko: Auto Collapse in Default Theme (1.1.13)
Kirjoitti: Biology Forums - toukokuu 24, 2011, 10:29:53 IP
How do I configure this so that it's automatically collapsed when a guest enters, as opposed to being opened by default?
Otsikko: Re: Auto Collapse in Default Theme (1.1.13)
Kirjoitti: Sir Osis of Liver - toukokuu 24, 2011, 11:19:51 IP
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>';



Otsikko: Re: Auto Collapse in Default Theme (1.1.13)
Kirjoitti: Biology Forums - toukokuu 24, 2011, 11:45:32 IP
Incredible, worked like a charm. O:)
Otsikko: Re: Auto Collapse in Default Theme (1.1.13)
Kirjoitti: Biology Forums - toukokuu 25, 2011, 01:02:13 AP
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.
Otsikko: Re: Auto Collapse in Default Theme (1.1.13)
Kirjoitti: 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', ';
Otsikko: Re: Auto Collapse in Default Theme (1.1.13)
Kirjoitti: Biology Forums - toukokuu 25, 2011, 12:42:22 IP
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.
Otsikko: Re: Auto Collapse in Default Theme (1.1.13)
Kirjoitti: Sir Osis of Liver - toukokuu 25, 2011, 11:08:13 IP
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.

Otsikko: Re: Auto Collapse in Default Theme (1.1.13)
Kirjoitti: Biology Forums - toukokuu 25, 2011, 11:29:52 IP
LainaaWorks tonight - no guarantee it'll work tomorrow.

lol, it worked.