Customization > Themes and Graphics

General Custom Theme Tutorial

(1/5) > >>

Nathaniel:
General Custom Theme Tutorial for SMF 1.1.x
This tutorial covers how to make edits to your SMF 1.1.x custom themes so that they will work perfectly with Simple Portal. Its possible that there may be a Custom Theme Tutorials for the theme that you have, so you should have a look through the list before using this tutorial.

Please note that this tutorial may not work for your custom theme. If that is the case and you can't find out where to make the edits yourself, then you can ask in the Themes and Graphics Board. Never post the contents of your index.template.php file, always attach that file to your post if you want help.

Do not ask for support in this topic! Please make a new topic in the Themes and Graphics Board.

All of the edits below are applied to your '/Themes/{themename}/index.template.php' template file. They are within the 'template_menu' function.

Adding the 'Forum' button:
This edit will be required for every custom theme, so that you have the actual forum button. Most themes use their own code for this section, so its most likely that you will have to copy one of the buttons in the 'template_menu' function and alter it so that it has the correct information. The easiest button/tab to copy is the 'Help' button, make a copy of the code for that button above the original code, and perform the changes below for the new code.

Find this code:

--- Code: ---$txt[119]
--- End code ---
Replace with this code:

--- Code: ---$txt['sp-forum']
--- End code ---

Find this code:

--- Code: ---href="', $scripturl, '?action=help"
--- End code ---
Replace with this code:

--- Code: ---href="', $scripturl . ($modSettings['sp_portal_mode'] == 1 ? '?action=forum' : ''), '"
--- End code ---

Find this code (It may occur more than once, or not at all):

--- Code: ---$current_action=='help'
--- End code ---
If you found it then replace it with this code:

--- Code: ---$current_action=='forum'
--- End code ---

You will also have to add this code before your new 'forum' button:

--- Code: ---if (empty($context['disable_sp']) && in_array($modSettings['sp_portal_mode'], array(1, 3)))
--- End code ---

If your help button looked something like this:

--- Code: ---   // Show the [help] button.
   echo ($current_action == 'help' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'help' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?action=help">' , $txt[119] , '</a>
            </td>' , $current_action == 'help' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
--- End code ---

Then you final forum button should look something like this:

--- Code: ---   // Show the [forum] button.
   if (empty($context['disable_sp']) && in_array($modSettings['sp_portal_mode'], array(1, 3)))
      echo ($current_action=='forum' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'forum' ? 'active_back' : 'back' , '">
               <a href="', $scripturl . ($modSettings['sp_portal_mode'] == 1 ? '?action=forum' : ''), '">', empty($txt['sp-forum']) ? 'Forum' : $txt['sp-forum'], '</a>
            </td>' , $current_action=='forum' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
--- End code ---

Adding the 'Forum' action:

Find this code:

--- Code: ---   $current_action = 'home';
--- End code ---

Replace with this code:

--- Code: ---   global $modSettings;
   $current_action = $modSettings['sp_portal_mode'] == 3 && empty($context['standalone']) && empty($context['disable_sp']) ? 'forum' : 'home';
--- End code ---

Find this code:

--- Code: ---'login', 'help', 'pm'
--- End code ---

Replace with this code:

--- Code: ---'login', 'help', 'pm', 'forum'
--- End code ---

Find this code:

--- Code: ---'smileys', 'viewErrorLog', 'viewmembers'
--- End code ---

Replace with this code:

--- Code: ---'smileys', 'viewErrorLog', 'viewmembers', 'manageportal'
--- End code ---

Find this code:

--- Code: ---      $current_action = 'search';
--- End code ---

Replace with this code:

--- Code: ---      $current_action = 'search';
   if (empty($context['disable_sp']) && (isset($_GET['board']) || isset($_GET['topic']) || in_array($context['current_action'], array('unread', 'unreadreplies'))) && in_array($modSettings['sp_portal_mode'], array(1, 3)))
      $current_action = 'forum';
--- End code ---

Editing the 'Home' button:
For standalone mode, you will have to edit the 'Home' button, so that 'Standalone Url' is used, instead of the normal forum url.

Find this code:

--- Code: ---href="', $scripturl, '"
--- End code ---

Replace with this code:

--- Code: ---href="', ($modSettings['sp_portal_mode'] == 3 && empty($context['disable_sp']) ? $modSettings['sp_standalone_url'] : $scripturl), '"
--- End code ---

Adding the SimplePortal images:
Copy the 'sp' images folder from your '/Themes/default/images/' folder into your '/Themes/{custom theme}/images/' folder. Please note that the default images may not look good with your custom theme, you may wish to consider making your own.

Adding the "Add as Article" button:
This edit is only required if your custom theme has its own '/Themes/{custom_theme}/Display.template.php' file.

Find this code ('/Themes/{custom_theme}/Display.template.php'):

--- Code: ---   // Show the page index... "Pages: [1]".
--- End code ---

Replace with this code:

--- Code: ---   // Make Article Button
   if ($context['can_make_article'])
      $normal_buttons['article'] = array('text' => 'sp-make_article', 'image' => 'addarticle.gif', 'lang' => true, 'url' => $context['portal_url'] . '?sa=addarticle;message=' . $context['topic_first_message'] . ';return=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']);

   // Show the page index... "Pages: [1]".
--- End code ---

SMF 2
SMF 2.0 doesn't need you to add any code to your custom themes, so the forum button should automatically work with SMF 2 and SimplePortal. Although if your theme uses images for each tab/button then you may need to make your own images.

Adding the SimplePortal images:
Copy the 'sp' and 'admin' images folders from your '/Themes/default/images/' folder into your '/Themes/{custom theme}/images/' folder. Please note that the default images may not look good with your custom theme, you may wish to consider making your own.

Adding the "Add as Article" button:
This edit is only required if your custom theme has its own '/Themes/{custom_theme}/Display.template.php' file.

Find this code ('/Themes/{custom_theme}/Display.template.php'):

--- Code: ---   // Show the page index... "Pages: [1]".
--- End code ---

Replace with this code:

--- Code: ---   // Make Article Button
   if ($context['can_make_article'])
      $normal_buttons['article'] = array('text' => 'sp-make_article', 'image' => 'addarticle.gif', 'lang' => true, 'url' => $context['portal_url'] . '?sa=addarticle;message=' . $context['topic_first_message'] . ';return=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']);

   // Show the page index... "Pages: [1]".
--- End code ---

Removing list dots that appear for some blocks/themes:
Open up your '/Themes/{custom theme}/style.css' file and add this code to the end:

--- Code: ---/* Reset sp lists. */
.spblock ul, .spblock ul li
{
   list-style: none;
}
--- End code ---

Edit: Updated for SP 2.2 (04 April 2009).
Edit: Updated with Display.template.php edits (12 June 2009).
Edit: Updated for SP 2.3.1 (3 October 2009).

probablepossible:
I feel kinda dumb but-- I can't see the tutorial at all! :o

Nathaniel:
No, nobody can. I was forgetful and started this topic, but never finishes it. I will try to complete it as soon as possible. Thanks for reminding me. ;)

Edit: Its updated now. :D

MrBI:
hi!

I did test this.
but my result is.
the home buttom become Forum but did linke to Portal
the Help buttom stay as Help but did link to Forum.

PS: yep I am a Noob. plz help me  D:

EDIT: I got it to work  :D
it's not

--- Code: ---$txt[103]
--- End code ---
it's

--- Code: ---$txt[119]
--- End code ---
Replace with this code:

--- Code: ---$txt['sp-forum']
--- End code ---

lou-in-usa:
$txt[] is an array. I did a print_r($txt) in the function template_button_strip function of the template file and then I copied the output to my text editor where I did a search for forum. I found the single word forum in about 1 minute. The key in my version of SWF1.1.7 is= ezp_forum_tab so in the button generating section I put $txt[ezp_forum_tab] and it worked perfectly.


Navigation

[0] Message Index

[#] Next page

Go to full version