Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

Auto Collapse in Default Theme (1.1.13)

Aloittaja Biology Forums, toukokuu 24, 2011, 10:29:53 IP

« edellinen - seuraava »

Biology Forums

How do I configure this so that it's automatically collapsed when a guest enters, as opposed to being opened by default?

Sir Osis of Liver

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>';



When in Emor, do as the Snamors.
                              - D. Lister


Biology Forums

#3
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.

MrGrumpy

Try this

change

var current_header = ', empty($options['collapse_header']) ? 'false' : 'true', ';

to

var current_header = ', empty($options['collapse_header']) ? 'true' : 'flase', ';
the possession of knowledge is worthless unless imparted upon others
My Custom Themes
2.0 themes only - I don't do 1.1.x

Biology Forums

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.

Sir Osis of Liver

#6
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.

When in Emor, do as the Snamors.
                              - D. Lister

Biology Forums

LainaaWorks tonight - no guarantee it'll work tomorrow.

lol, it worked.

Advertisement: