TinyPortal Docs

Documentation For TP .98 => TP Doc's => TP .98 => How To's => Topic started by: Xarcell on April 24, 2008, 04:42:02 PM

Title: How Do I Add An Extra Button To the Theme?
Post by: Xarcell on April 24, 2008, 04:42:02 PM
basically in your index.template.php file (in the theme folder)

search for this:


if (in_array($context['current_action'], array('links','search', 'admin', 'arcade','calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'forum', 'tpadmin')))
$current_action = $context['current_action'];


its before all the buttons code if u cant find it via a search - or u could always do a partial search beginning with if (in_array($context['current_action'] so atleast it will get u to the correct line incase the code had been altered by a mod earlier.

To it add your Array text (shows as YOUR-ARRAY-TEXT but in reality it will be the action u are adding like arcade, or links etc)

if (in_array($context['current_action'], array('links','search', 'admin', 'arcade','calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'forum', 'tpadmin', 'YOUR-ARRAY-TEXT')))
$current_action = $context['current_action'];


In the above where it says YOUR-ARRAY-TEXT u will put your link action like if ur adding a gallery button then u can name it gallery

next look for this line:

   // Show the [help] button.

depending on the theme (since each theme may use different button codes) the button codes below will be something like this:


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



you just have to copy that code and change all the instances of help in the code above to:


// Show the [YOUR-BUTTON-TEXT] button.
echo ($current_action == 'YOUR-ARRAY-TEXT' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'YOUR-ARRAY-TEXT' ? 'active_back' : 'back' , '">
<a href="YOUR-LINK-HERE">YOUR-BUTTON-TEXT</a>
</td>' , $current_action == 'YOUR-ARRAY-TEXT' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


then add this code just before the    // Show the [help] button.

replace in it:
YOUR-ARRAY-TEXT >> with the array you declared in the 1st code change

YOUR-BUTTON-TEXT the text you want your button to show

YOUR-LINK-HERE >> add the url you want associated with that button
-------------------------

this is for default template

for theme specific the procedure is the same but the code will differ slightly for each theme but dont be alarmed if the code is different, just study the code a bit to see how each button is declared and just copy the code for a single button and add it below one of the other button codes. If you cant do it at all even after using this doc, please post a topic i the support forums asking for help.



Doc Written By: G6