Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Everyday SMF Customizations
#1
Whether your wanting to start customizing the source or just getting familiar with adding features, knowing how to do things with forum software is essential to solving problems and knowing how to effectively use features provided for you.

Below are some key topics which will help guide your way through SMF.


Adding new navigation tabs

Adding new tabs to the navigation bar is what most people want to do when customizing. How to do this with SMF 2.0? First off, head into your Sources/Subs.php and search for the following code,
PHP Code:
'home' => array(
    
'title' => $txt['home'],
    
'href' => $scripturl,
    
'show' => true,
    
'sub_buttons' => array(
    ),
    
'is_last' => $context['right_to_left'],
   ), 
You guessed it! This array holds information for the Home tab. Adding a new tab is simple, just add it according to what position you want it displayed in. For example, if you wanted a new tab beside the Home tab on the nav bar, add this code directly under that one,
PHP Code:
'button_name' => array(
    
'title' => 'The Tab Title',
    
'href' => 'the hyperlink reference to where it should go (the link)',
    
'show' => true// boolean value indicating whether to display it or not
    
'sub_buttons' => array( // additional buttons you want displayed (dropdown buttons)
       // if you want a dropdown button, simple add the same above:
       // title, href, and show
    
),
   ), 

In SMF 1.1.x, open your Theme/index.template.php, and find the following,
PHP Code:
// Show the [home] button. 
Below that will be a snippet for the home button. If you want to add a new button, just place it under the tab you want it to appear beside, as such,
PHP Code:
echo ($current_action=='action_name' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' $first '">&nbsp;</td>' '' '
    <td valign="top" class="maintab_' 
$current_action == 'action_name' 'active_back' 'back' '">
     <a href="LINK HERE">TAB TITLE HERE</a>
    </td>' 
$current_action == 'action_name' '<td class="maintab_active_' $last '">&nbsp;</td>' ''
That should be pretty self-explanatory. Incase your wondering what the $current_action variable does, its simply a variable that stores the current action from your action GET array. So if your currently on: http://mysite.com/index.php?action=lolwut
The $current_variable will store that as its value. Also, before I forget, for SMF 1.1.x, to have the tab show properly find,
PHP Code:
if ($context['current_action'] == 'search2')
  
$current_action 'search'
And add this snippet below,
PHP Code:
if ($context['current_action'] == 'action_name')
  
$current_action 'action_name'
Or you can simply just place it in the above if-statement.


Adding content around the copyright

This next topic will show you how to add content above that [URL="http://www.simplemachines.org/"]Powered by SMF 1.1.12[/URL] | [URL="http://www.simplemachines.org/about/copyright.php"]SMF © 2006-2009, Simple Machines LLC[/URL] string. In SMF 2.0 its real easy, and I can say the same for the 1.1.x version as well. Head into your Theme/index.template.php file and search for the following,
PHP Code:
<li class="copyright">', theme_copyright(), '</li
Its as simple as appending a break line (<br />) tag to the first apostrophe and adding text before it. As such,
PHP Code:
<li class="copyright">This is a usefulcentered string. :D<br />', theme_copyright(), '</li

In 1.1.x its just about the same place, head into the same file and search for,
PHP Code:
<td valign="middle" align="center" style="white-space: nowrap;"
PHP Code:
', theme_copyright(), '
    
</td
Hopefully you get it by now.


Adding content to every SMF page

Ever notice how some parts such as the user header is displayed in all pages? Its simple, editting the main template file directly. In SMF 2.0, search for the following,
PHP Code:
// The main content should go here. 
PHP Code:
echo '
 <div id="content_section"><div class="frame">
  <div id="main_content_section">'
;
 
// Custom banners and shoutboxes should be placed here, before the linktree. 
And below that last line you would add your content in an echo and such.

In SMF 1.1.x search for the same file (Theme/index.template.php) and search for,
PHP Code:
// The main content should go here. 
PHP Code:
echo '<div id="bodyarea" style="padding: 1ex 0px 2ex 0px;">'
Under that echo just add your content.


Adding new pages to SMF (not very basic)

Since this is a more broad topic, the tutorial can be found here,
http://www.supportforums.net/showthread.php?tid=15449


Additional Resources


I use the following resources when looking for already existing tune-ups or tutorials on utilizing SMF;
If you would like any more topics added feel free to leave a comment below. V
Thanks for reading.
My SMF Modifications:
http://anthony.vibrantvps.com/smf
Reply
#2
I love SMF, but I still feel they should do more for templates. For example when I used it the mods for custom tabs would only work on the default theme and I ran into all sorts of errors.

However, nice tutorial PE.
Reply
#3
(01-09-2011, 05:36 PM)Sam Wrote: I love SMF, but I still feel they should do more for templates. For example when I used it the mods for custom tabs would only work on the default theme and I ran into all sorts of errors.

However, nice tutorial PE.

I agree, the template system relies too heavily on itself to be clear of mod interference. However, there are techniques such as replacing the template dynamically from the source file.

And thanks.

My SMF Modifications:
http://anthony.vibrantvps.com/smf
Reply
#4
Nice share dude Smile
Reply
#5
Nice and simple, thanks.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SMF Modification Parser Project Evolution 0 855 01-15-2011, 01:37 PM
Last Post: Project Evolution
  Creating new pages in SMF Project Evolution 3 5,674 01-10-2011, 06:28 AM
Last Post: w00pz
  [SMF] Basic Server-Side Includes (SSI) Project Evolution 2 1,474 08-30-2010, 05:42 PM
Last Post: Project Evolution

Forum Jump:


Users browsing this thread: 2 Guest(s)