• Welcome to Simple Machines Community Forum. Please login or sign up.
November 30, 2021, 11:18:10 PM

News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord


Theme alterations made in RC2

Started by Grudge, November 23, 2005, 05:58:36 PM

Previous topic - Next topic

Grudge

November 23, 2005, 05:58:36 PM Last Edit: January 09, 2006, 06:31:48 AM by Grudge
All,

With 1.1 RC2, there have been several changes to the templates. Although these shouldn't stop your custom themes from working, to increase speed, and in some cases security, you may want to manually make the changes suggested here. The main changes that have occured are:

1) The new default theme has meant an alteration of several templates.
2) Global javascript sessions have been removed to increase security in SMF.

EDIT: You may also wish to view this topic.

The upgrade script will do it's best to preserve existing themes to make them look right with 1.1 RC2. If you want to make your old templates right up to date, then follow the set of simple instructions for upgrading your themes below:

Compatibility Template
In order to ensure all old themes work with SMF 1.1 RC2, a compatibility template was introducted into the default theme. If you have an old theme this is required to stop errors. As a result of this a small performance hit will result as two templates are loaded each page load instead of one. To optimise your old themes, it's recommended that you copy the function calls in Combat.template.php into the bottom of your theme's index.template.php. So, simply open up your themes index.template.php file and copy and paste the below code at the bottom of the file, just above the "?>"


// Generate a strip of buttons, out of buttons.
function template_button_strip($button_strip, $direction = 'top')
{
global $settings, $buttons, $context, $txt, $scripturl;

if (empty($button_strip))
return '';

// Create the buttons...
foreach ($button_strip as $key => $value)
{
if (isset($value['test']) && empty($context[$value['test']]))
{
unset($button_strip[$key]);
continue;
}
elseif (!isset($buttons[$key]))
$buttons[$key] = '<a href="' . $value['url'] . '" ' .( isset($value['custom']) ? $value['custom'] : '') . '>' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . ($value['lang'] ? $context['user']['language'] . '/' : '') . $value['image'] . '" alt="' . $txt[$value['text']] . '" border="0" />' : $txt[$value['text']]) . '</a>';

$button_strip[$key] = $buttons[$key];
}

echo '
<td>', implode($context['menu_separator'], $button_strip) , '</td>';
}


smf_setThemeOption
This javascript function is often used in the index template for doing the upshrink. As of RC2 it requires an extra parameter for security, the session id. To add this simply find your current smf_setThemeOption calls, and add "' . $context['session_id'] . '" on the end. For example, if you had this:


smf_setThemeOption("collapse_header", mode ? 1 : 0);


It needs to become this:

smf_setThemeOption("collapse_header", mode ? 1 : 0, null, "' . $context['session_id'] . '")';


Note that if, as the above example shows, you don't use the optional third parameter, set it to null as above.

hash password
The other major change, is to the function called hashLoginPassword. Again, this now needs the session ID passed to it. To do so simply find any calls to hashLoginPassword and replace it with that shown below. So if you had:


hashLoginPassword(this);


It needs to become:

hashLoginPassword(this, \'' . $context['session_id'] . '\');


These should be the only javascript problems likely to be encountered on the average custom theme.

Note that there will be no other template changes between now and final - so you don't have to worry about doing this more than once!



Remove Image Border
Add this line anywhere in styles.css of your themes.

/* No image should have a border when linked */
a img
{
   border: 0;
}




Change the color of sticky topics cell
In style.css for your themes search for catbg and catbg2 you will find about 10 lines that belong to those tags.  Replace them with this.

/* This is used for categories, page indexes, and several other areas in the forum. */
.catbg, .catbg3
{
background-image: url(images/catbg.jpg);
}

/* This is used for a category that has new posts in it... to make it light up. */
.catbg2
{
background-image: url(images/catbg2.jpg);
}

.catbg, .catbg2, .catbg3
{
font-weight: bold;
background-color: silver;
color: #000000;
}


Then search for windowbg and add this after windowbg2.  Change the color to go along with your theme's color.
.windowbg3
{
        color: #000000;
        background-color: #CCCCCC;
}


EDIT: Added ' to this smf_setThemeOption("collapse_header", mode ? 1 : 0, null, "' . $context['session_id'] . '")';
EDIT: Added How to remove image border.
EDIT: Added How to change the sticky topic cell color.
I'm only a half geek really...

jasidog

A quick queston if anyone has the answer.

I'm updating a couple of themes and the the way the help pages are done has changed.  With the new additions to the help.template.

That's all fine but on one of the themes i noticed some odd display issues, these were caused by the help CSS file. It used to be the help pages would use the help.css file in the theme's help directory but with RC2 I found this when viewing the source -

<link rel="stylesheet" type="text/css" href="http://localhost/smf/Themes/default/help.css" />

It's linking to the default theme's help.css file. I can't seem to find where to alter this any ideas?

Grudge

December 24, 2005, 08:41:53 AM #2 Last Edit: December 24, 2005, 08:44:06 AM by Grudge
This was done to stop it from breaking any old themes, I will fix this in RC2 Public so that it uses the current themes css file if it exists.

* Use the current themes help.css file if it exists. (Help.php)
I'm only a half geek really...

jasidog

Ah, cool. Thanks very much for the quick help Grudge! It's apreciated! :)

Gargoyle

Quote
hash password
The other major change, is to the function called hashLoginPassword. Again, this now needs the session ID passed to it. To do so simply find any calls to hashLoginPassword and replace it with that shown below. So if you had:

Copy to clipboardCode:
hashLoginPassword(this);

It needs to become:
Copy to clipboardCode:
hashLoginPassword(this, \'' . $context['session_id'] . '\');



This section of the edits causes an error in my Helios theme...

Quote
<form action="', $scripturl, '?action=login2" method="post" style="margin: 3px 1ex 1px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>

Gargoyle

December 24, 2005, 12:25:13 PM #5 Last Edit: December 24, 2005, 12:28:08 PM by Gargoyle
O'kay actually the smf_setThemeOption causes the template parse errors.

Grudge

Can you post the template code 5 lines either side of where you made the edit?
I'm only a half geek really...

Gargoyle

// 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" : "";

                        current_header = mode;
                }
        // ]]></script>


There ya go.. Thanks for taking a look at it..  :D

Grudge

This:

smf_setThemeOption("collapse_header", mode ? 1 : 0, null, "' . $context['session_id'] . '");


Becomes:

smf_setThemeOption("collapse_header", mode ? 1 : 0, null, "' . $context['session_id'] . '")';


when you made the change you didn't keep the ' before the semi-colon
I'm only a half geek really...

Gargoyle

Your code in the above post has no ' in it before the semicolon.

Thanks for the fix... ;D

Gargoyle

One more question.....

How do I add the inline editing to my Theme(s)  ??

Many thanks... ;D

bloc

I will update Helios and any other theme of mine shortly. Those themes that don't use Display.template but rather fallback on default theme, should have inline editing though.

But again, I haven't started testing/converting any of them yet.

Gargoyle

Thanks for the input Bloc... I will await the release of your updated themes then.

McNeo2

December 31, 2005, 10:48:36 AM #13 Last Edit: December 31, 2005, 10:54:00 AM by McNeo2
using: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5



ps. this anomaly was visible until this post was the last one. After the next post, it looked normal again.


xtremecruiser

I have 5 different 1.1 templates on my site, I will give this a good test tonight :-X

TarantinoArchives

Quote from: Grudge on November 23, 2005, 05:58:36 PM

hash password
The other major change, is to the function called hashLoginPassword. Again, this now needs the session ID passed to it. To do so simply find any calls to hashLoginPassword and replace it with that shown below. So if you had:


hashLoginPassword(this);


It needs to become:

hashLoginPassword(this, \'' . $context['session_id'] . '\');


i don't find this. am I blind? I have hashPassword(this) but not hashLoginPassword(this)

† ÐëepÇuT¹ †

December 31, 2005, 03:18:02 PM #16 Last Edit: December 31, 2005, 09:21:46 PM by † ÐëepÇuT¹ †
How can I include the inline edit feature into a theme.. I've tried pasting this at the right spot in my themes MessageIndex.template.php..


// Javascript for inline editing.
echo '
<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . '/xml_board.js"></script>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[

// Hide certain bits during topic edit.
hide_prefixes.push("lockicon", "stickyicon", "pages", "newicon");

// Use it to detect when we\'ve stopped editing.
document.onmousedown = mouse_down;

var mouse_on_div;
function mouse_down(e)
{
if (in_edit_mode == 1 && mouse_on_div == 0)
modify_topic_save("', $context['session_id'], '");
}

// For templating, shown when an inline edit is made.
function modify_topic_show_edit(subject)
{
// Just template the subject.
setInnerHTML(cur_subject_div, \'<input type="text" name="subject" value="\' + subject + \'" size="60" style="width: 99%;"  maxlength="80" /><input type="hidden" name="topic" value="\' + cur_topic_id + \'" /><input type="hidden" name="msg" value="\' + cur_msg_id.substr(4) + \'" />\');
}

// And the reverse for hiding it.
function modify_topic_hide_edit(subject)
{
// Re-template the subject!
setInnerHTML(cur_subject_div, \'<a href="', $scripturl, '?topic=\' + cur_topic_id + \'.0">\' + subject + \'</a>\');
}

// ]]></script>';
}

function theme_show_buttons()
{
global $context, $settings, $options, $txt, $scripturl;

$buttonArray = array();



Personal Website
x3Generation - gaming
graphics and anime.
 

Favorite Forums
> SimpleMachines Forum
> GamerzPlanet Forums


Tye

Where do I find the Hash login Session thing?

xtremecruiser

Someone please help fix DeepCuts theme 8)

JayBachatero

@McNeo2 - This is more of a FF issue.  It has been around for a while now ;)

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Advertisement: