[1.1] How to add tabs to Core (NDT)?

Started by JayBachatero, December 31, 2005, 04:21:57 PM

Previous topic - Next topic

IchBin™

haha! Good work! I knew you could do it! :)
IchBin™        TinyPortal

gamerhookup

Ok, instead of opening an new topic this is related, but not something I have found.. Hopefully i can explain it...

k, I have the 2 new tabs up and working and all that. What is new is that I used the Forums for one tab and the other for Articles under tinyportal. So they are just links. One is an about page in the forum and the other is a guild history in the other tab. Now you see where I am starting from.

The problem is when you click on either tab you do not get an active button lit tab, you get the forum tab in one cause thats where you are. Is ther ea way to make the forum articles show up as an active tab and not the forum even though your in there?

Did that make sense? In other words all tabs lit up except those two, one lit for the forums and one lit for home since it is the tiny portal Article section..

Now I am still fairly new to SMF and yet to find a better looking mod to do what I am looking at unless who reads this can pass me on to a link or a better idea...???

Help, is there any way?

IchBin™

If your extra/custom pages do not have an action=page_name then the highlight will not work, unless there is something in your URL that you can identify it by. What are the links to the pages? Maybe someone can write you up a quick piece of code to make it work.
IchBin™        TinyPortal

gamerhookup

Well since I am using the forums to do this, do you have any idea if there is a mod out there or one that can be written for like a clab/guild/about pages.. 

All this is, is just an area to display what the clan is about and the charter history and a few other thigs on what it is there and how it got there.


http://www.mydomainname.net/index.php?page=6



http://www.mydomainname.net/index.php?topic=22.msg98


Those are the two links, I am willing to do something new, I am just not that good at PHP developement or design for that nature, I can only work out  the details.

Amyhow, any thing you can throw my way as what would or could help would be so greatfull.
Thanks

IchBin™

Put this code in towards the top of the template_menu() function where you see the other $current_action array variables getting set.
if (isset($_GET['page']) && $_GET['page'] == 6)
    $current_action = 'page6';

if (isset($_GET['topic']) && $_GET['topic'] == 22)
    $current_action = 'topic22';


Then in your button, replace all of the current_action stuff to match your code above depending on which button it is. <td class="maintab_back', $current_action == 'page6'> etc.
IchBin™        TinyPortal

gamerhookup

#485
Ok thanks man... The page 6 line worked, but not the forum topic 22 you supplied., So I tried a few other things and so far nothing, So the page 6 fromt he articles section works 100 percent and the button is lit..

Here is what I have so you can tell me if I missed up or am missing something else...


Template action:

if (isset($_GET['page']) && $_GET['page'] == 6)    $current_action = 'page6';if (isset($_GET['topic']) && $_GET['topic'] == 22)    $current_action = 'topic=22.msg98';

if ($context['current_action'] == 'aboutus')
$current_action = 'page6';

if ($context['current_action'] == 'guildhistory')
$current_action = 'topic=22.msg98';


button area:

// Show the [aboutus] button.
echo ($current_action=='page6' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'page6' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?page=6">' , $txt[2000] , '</a>
</td>' , $current_action == 'page6' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Show the [guildhistory] button.
echo ($current_action=='topic=22.msg98' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'topic=22.msg98' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?topic=22.msg98">' , $txt[2001] , '</a>
</td>' , $current_action == 'topic=22.msg98' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


K, there ya go, any ideas or did I enter something wrong, keep in mind I only added the .msg98 to the topic 22 since it did not work and that is the action link it is trying to pull...

UPDATE:

I forgot a few of the current actions, no matter still not worked, so i took out all the ms98 to the topic 22 and still nothing, the forum lites up no matter what...(since that is where it is)

If you or we can not fix it, i will just enter a new article and go that route since the about page works now. Inless there is a mod out there that is better..

Thanks for your help!!!!!!

Sandokan2

Hi everyone, I have tried several times to add a button but just can't make it work  :'(
I read every single detail of the tut and still get something else. Who can help me?
I want a new button that says: Video Items and it needs to point to a URL:

http://www.gameroad.nl/videoitems.hml

The file doesn't excist yet but it just needs to point there. Can anyone help me by editing my
Index.template.php? Thanx!!

This is my forum URL:

http://www.gameroad.nl/

My clean unedited index.template.php:

<?php
// Version: 1.1; index

/* This template is, perhaps, the most important template in the theme. It
contains the main template layer that displays the header and footer of
the forum, namely with main_above and main_below. It also contains the
menu sub template, which appropriately displays the menu; the init sub
template, which is there to set the theme up; (init can be missing.) and
the linktree sub template, which sorts out the link tree.

The init sub template should load any data and set any hardcoded options.

The main_above sub template is what is shown above the main content, and
should contain anything that should be shown up there.

The main_below sub template, conversely, is shown after the main content.
It should probably contain the copyright statement and some other things.

The linktree sub template should display the link tree, using the data
in the $context['linktree'] variable.

The menu sub template should display all the relevant buttons the user
wants and or needs.

For more information on the templating system, please see the site at:
http://www.simplemachines.org/
*/

// Initialize the template... mainly little settings.
function template_init()
{
global $context$settings$options$txt;

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';

/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '1.1';

/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;

/* Use plain buttons - as oppossed to text buttons? */
$settings['use_buttons'] = true;

/* Show sticky and lock status seperate from topic icons? */
$settings['seperate_sticky_lock'] = true;

$settings['tp_images_url'] = $settings['images_url'] . '/tinyportal';
}

// The main sub template above the content.
function template_main_above()
{
global $context$settings$options$scripturl$txt$modSettings$boardurl;

// Show right to left and the character set for ease of translating.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"'
$context['right_to_left'] ? ' dir="rtl"' '''><head>
<meta http-equiv="Content-Type" content="text/html; charset='
$context['character_set'], '" />
<meta name="description" content="'
$context['page_title'], '" />
<meta name="keywords" content="PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum" />
<script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/script.js?rc2p"></script>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var smf_theme_url = "'
$settings['theme_url'], '";
var smf_images_url = "'
$settings['images_url'], '";
var smf_scripturl = "'
$scripturl'";
// ]]></script>
<title>'
$context['forum_name'] . ' : ' $context['page_title'], '</title>';

// The ?rc2 part of this link is just here to make sure browsers don't cache it wrongly.
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/style.css?rc2" />
<link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/print.css?rc2" media="print" />';

/* Internet Explorer 4/5 and Opera 6 just don't do font sizes properly. (they are big...)
Thus, in Internet Explorer 4, 5, and Opera 6 this will show fonts one size smaller than usual.
Note that this is affected by whether IE 6 is in standards compliance mode.. if not, it will also be big.
Standards compliance mode happens when you use xhtml... */
if ($context['browser']['needs_size_fix'])
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/fonts-compat.css" />';

// Show all the relative links, such as help, search, contents, and the like.
echo '
<link rel="help" href="'
$scripturl'?action=help" target="_blank" />
<link rel="zoeken" href="' 
$scripturl '?action=search" />
<link rel="contents" href="'
$scripturl'" />';

// If RSS feeds are enabled, advertise the presence of one.
if (!empty($modSettings['xmlnews_enable']))
echo '
<link rel="alternate" type="application/rss+xml" title="'
$context['forum_name'], ' - RSS" href="'$scripturl'?type=rss;action=.xml" />';

// If we're viewing a topic, these should be the previous and next topics, respectively.
if (!empty($context['current_topic']))
echo '
<link rel="prev" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=prev" />
<link rel="next" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=next" />';

// If we're in a board, or a topic for that matter, the index will be the board's index.
if (!empty($context['current_board']))
echo '
<link rel="index" href="' 
$scripturl '?board=' $context['current_board'] . '.0" />';


// We'll have to use the cookie to remember the header...
if ($context['user']['is_guest'])
$options['collapse_header'] = !empty($_COOKIE['upshrink']);

// Output any remaining HTML headers. (from mods, maybe?)
echo $context['html_headers'], '
<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" : "";

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

// the routine for the info center upshrink
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var current_header_ic = '
, empty($options['collapse_header_ic']) ? 'false' 'true'';

function shrinkHeaderIC(mode)
{'
;

if ($context['user']['is_guest'])
echo '
document.cookie = "upshrinkIC=" + (mode ? 1 : 0);'
;
else
echo '
smf_setThemeOption("collapse_header_ic", mode ? 1 : 0, null, "'
$context['session_id'], '");';

echo '
document.getElementById("upshrink_ic").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");

document.getElementById("upshrinkHeaderIC").style.display = mode ? "none" : "";

current_header_ic = mode;
}
// ]]></script>'
;

echo '
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="searcharea">
<form action="'
$scripturl'?action=search2" method="post" accept-charset="'$context['character_set'], '">
<input class="inputbox" type="text" name="search" value="'
$txt[182], '..." onfocus="this.value = \'\';" onblur="if(this.value==\'\') this.value=\''$txt[182], '...\';" />';

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="'
$context['current_topic'], '" />';

// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd['
$context['current_board'], ']" value="'$context['current_board'], '" />';

echo '
</form>
</div>
<div id="logo"><a href="'
.$scripturl.'" title=""></a></div>
</div>
<div id="shad-tr">
<div id="shad-tl">
<div id="toolbar">
'
,template_menu(),'
</div>
<div id="toparea">
<div id="userarea">'
;
if(!empty($context['user']['avatar']))
echo '
<div class="ds-avatar">'
.$context['user']['avatar']['image'].'</div>';
// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{
echo '
<ul>
<li><b>'
$txt['hello_member_ndt'], ' '$context['user']['name'],'</b></li>';

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
echo '
<li><a href="'
$scripturl'?action=pm">'$context['user']['messages'], ' '$context['user']['messages'] != $txt[153] : $txt[471], '</a>'$txt['newmessages4'], ' '$context['user']['unread_messages'], ' '$context['user']['unread_messages'] == $txt['newmessages0'] : $txt['newmessages1'],'</li>';

// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '<li><b>'$txt[616], '</b></li>';

// Are there any members waiting for approval?
if (!empty($context['unapproved_members']))
echo '<li>'$context['unapproved_members'] == $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="'$scripturl'?action=viewmembers;sa=browse;type=approve">'$context['unapproved_members'] == $txt['approve_member'] : $context['unapproved_members'] . ' ' $txt['approve_members'], '</a> '$txt['approve_members_waiting'], '</li>';

echo '
<li><a href="'
$scripturl'?action=unread">'$txt['unread_since_visit'], '</a></li>
<li><a href="'
$scripturl'?action=unreadreplies">'$txt['show_unread_replies'], '</a></li>
</ul>'
;
}
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
else
{
echo '
'
$txt['welcome_guest'], '
<script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/sha1.js"></script>
<form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '" style="margin: 4px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' $context['session_id'] . '\');"' '''>
<input type="text" name="user"  size="10" />
<input type="password" name="passwrd"  size="10" />
<select name="cookielength">
<option value="60">'
$txt['smf53'], '</option>
<option value="1440">'
$txt['smf47'], '</option>
<option value="10080">'
$txt['smf48'], '</option>
<option value="43200">'
$txt['smf49'], '</option>
<option value="-1" selected="selected">'
$txt['smf50'], '</option>
</select>
<input type="submit" value="'
$txt[34], '" />
<input type="hidden" name="hash_passwrd" value="" />
</form>'
$txt['smf52'], '<br /><br />';
}

echo '
</div>
<div id="news">'
;
if (!empty($settings['enable_news']))
echo '
<span class="smalltext"><strong>'
$txt[102], '</strong>:<br />'$context['random_news_line'], '</span>';
echo '
</div>
</div>
<div class="clr"></div>
<div id="bodyarea">'
;
}

function 
template_main_below()
{
global $context$settings$options$scripturl$txt$user_info;

echo '
</div>
</div>
</div>'
;

echo '
<div id="shad-b">
<div id="shad-bl">
<div id="shad-br">
<div id="footer">
<span class="smalltext">'
theme_copyright(), '<br />
<strong>Indigo</strong> design by <a href="http://www.dzinerstudio.com" target="_blank">DzinerStudio</a></span>'
;

// Show the load time?
if ($context['show_load_time'])
echo '<br /><span class="smalltext">'$txt['smf301'], $context['load_time'], $txt['smf302'], $context['load_queries'], $txt['smf302b'], '</span>';

echo '
</div>
</div>
</div>
</div>'
;

echo 
'
</div>
</body></html>'
;
}

// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree()
{
global $context$settings$options;

echo '
<div class="pathway">'
;
// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'];

// Don't show a separator for the last one.
if ($link_num != count($context['linktree']) - 1)
// Show the link, including a URL if it should have one.
echo $settings['linktree_link'] && isset($tree['url']) ? '<a href="' $tree['url'] . '">' $tree['name'] . '</a>' $tree['name'] , '&nbsp;&laquo;&nbsp;';
else
echo $tree['name'];

// Show something after the link...?
if (isset($tree['extra_after']))
echo $tree['extra_after'];

}

echo '</div>';
}

// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context$settings$options$scripturl$txt;

// Work out where we currently are.
$current_action 'home';
if (in_array($context['current_action'], array('admin''ban''boardrecount''cleanperms''detailedversion''dumpdb''featuresettings''featuresettings2''findmember''maintain''manageattachments''manageboards''managecalendar''managesearch''membergroups''modlog''news''optimizetables''packageget''packages''permissions''pgdownload''postsettings''regcenter''repairboards''reports''serversettings''serversettings2''smileys''viewErrorLog''viewmembers')))
$current_action 'admin';
if (in_array($context['current_action'], array('search''admin''calendar''profile''mlist''register''login''help''pm''forum''tpadmin')))
$current_action $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action 'search';

if (isset($_GET['dl']))
$current_action 'dlmanager';

if (isset($_GET['board']) || isset($_GET['topic']) || $context['current_action']=='forum')
$current_action 'forum';

if ($context['current_action']=='tpadmin')
$current_action 'admin';

if ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' 'profile' 'admin';

// Are we using right-to-left orientation?
if ($context['right_to_left'])
{
$first 'last';
$last 'first';
}
else
{
$first 'first';
$last 'last';
}

// Show the start of the tab section.

echo '
<div id="topmenu">
<ul>'
;

// Show the [home] button.
echo '<li><a' $current_action=='home' ' class="current"' '' ' href="'$scripturl'">' $txt[103] , '</a></li>';

if($settings['TPortal_front_type']!='boardindex')
// Show the [forum] button.
echo '<li><a' $current_action=='forum' ' class="current"' '' ' href="'$scripturl'?action=forum">' $txt['tp-forum'] , '</a></li>';

// Show the [help] button.
echo '<li><a' $current_action=='help' ' class="current"' '' ' href="'$scripturl'?action=help">' $txt[119] , '</a></li>';

// How about the [zoeken] button?
if ($context['allow_search'])
echo '<li><a' $current_action=='search' ' class="current"' '' ' href="'$scripturl'?action=search">' $txt[182] , '</a></li>';

// The [kalender]!
if ($context['allow_calendar'])
echo '<li><a' $current_action=='calendar' ' class="current"' '' ' href="'$scripturl'?action=calendar">' $txt['calendar24'] , '</a></li>'

// Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin'])
echo '<li><a' $current_action=='admin' ' class="current"' '' ' href="'$scripturl'?action=admin">' $txt[2] , '</a></li>';

// Edit Profile... [profiel]
if ($context['allow_edit_profile'])
echo '<li><a' $current_action=='profile' ' class="current"' '' ' href="'$scripturl'?action=profile">' $txt[79] , '</a></li>';

// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo '<li><a' $current_action=='pm' ' class="current"' '' ' href="'$scripturl'?action=pm">' $txt['pm_short'] , ' '$context['user']['unread_messages'] > '[<strong>'$context['user']['unread_messages'] . '</strong>]' '' '</a></li>';

// the [leden] list button
if ($context['allow_memberlist'])
echo '<li><a ' $current_action=='mlist' ' class="current"' '' ' href="'$scripturl'?action=mlist">' $txt[331] , '</a></li>';

// If the user is a guest, show [login] button.
if ($context['user']['is_guest'])
echo '<li><a ' $current_action=='login' ' class="current"' '' ' href="'$scripturl'?action=login">' $txt[34] , '</a></li>';

// If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo '<li><a ' $current_action=='register' ' class="current"' '' ' href="'$scripturl'?action=register">' $txt[97] , '</a></li>';

// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo '<li><a ' $current_action=='logout' ' class="current"' '' 'href="'$scripturl'?action=logout;sesc='$context['session_id'], '">' $txt[108] , '</a></li>';

echo '</ul>
</div>'
;
}

// Generate a strip of buttons.
function template_button_strip($button_strip$direction 'top'$force_reset false$custom_td '')
{
global $settings$buttons$context$txt$scripturl;

// 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]) || $force_reset)
$buttons[$key] = '<a href="' $value['url'] . '" ' .( isset($value['custom']) ? $value['custom'] : '') . '>' $txt[$value['text']] . '</a>';

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

if (empty($button_strip))
return '<td>&nbsp;</td>';

echo '
<td class="'
$direction == 'top' 'main' 'mirror''tab_' $context['right_to_left'] ? 'last' 'first' '">&nbsp;</td>
<td class="'
$direction == 'top' 'main' 'mirror''tab_back">'implode(' &nbsp;|&nbsp; '$button_strip) , '</td>
<td class="'
$direction == 'top' 'main' 'mirror''tab_' $context['right_to_left'] ? 'first' 'last' '">&nbsp;</td>';
}

?>


Thank you  :D

IchBin™

Quote from: gamerhookup on August 19, 2008, 11:20:14 PM
Ok thanks man... The page 6 line worked, but not the forum topic 22 you supplied., So I tried a few other things and so far nothing, So the page 6 fromt he articles section works 100 percent and the button is lit..

Here is what I have so you can tell me if I missed up or am missing something else...


Template action:

if (isset($_GET['page']) && $_GET['page'] == 6)    $current_action = 'page6';if (isset($_GET['topic']) && $_GET['topic'] == 22)    $current_action = 'topic=22.msg98';

if ($context['current_action'] == 'aboutus')
$current_action = 'page6';

if ($context['current_action'] == 'guildhistory')
$current_action = 'topic=22.msg98';


button area:

// Show the [aboutus] button.
echo ($current_action=='page6' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'page6' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?page=6">' , $txt[2000] , '</a>
</td>' , $current_action == 'page6' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Show the [guildhistory] button.
echo ($current_action=='topic=22.msg98' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'topic=22.msg98' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?topic=22.msg98">' , $txt[2001] , '</a>
</td>' , $current_action == 'topic=22.msg98' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


K, there ya go, any ideas or did I enter something wrong, keep in mind I only added the .msg98 to the topic 22 since it did not work and that is the action link it is trying to pull...

UPDATE:

I forgot a few of the current actions, no matter still not worked, so i took out all the ms98 to the topic 22 and still nothing, the forum lites up no matter what...(since that is where it is)

If you or we can not fix it, i will just enter a new article and go that route since the about page works now. Inless there is a mod out there that is better..

Thanks for your help!!!!!!

$current_action = 'topic=22.msg98'; needs to be $current_action = 'topic22'; at the top.

The button code should look like this:
   // Show the [guildhistory] button.
   echo ($current_action=='topic22' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'topic22' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?topic=22.msg98">' , $txt[2001] , '</a>
            </td>' , $current_action == 'topic22' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
IchBin™        TinyPortal

IchBin™

Quote from: Sandokan2 on August 20, 2008, 07:20:39 AM
Hi everyone, I have tried several times to add a button but just can't make it work  :'(
I read every single detail of the tut and still get something else. Who can help me?
I want a new button that says: Video Items and it needs to point to a URL:

http://www.gameroad.nl/videoitems.hml

The file doesn't excist yet but it just needs to point there. Can anyone help me by editing my
Index.template.php? Thanx!!

This is my forum URL:

http://www.gameroad.nl/

My clean unedited index.template.php:

Thank you  :D

There's no need to post the whole index.template.php file. If you want help with a custom theme, you should first seek help from the author. Not all themes are the same. This theme's button you posted are not the same as what this topic is about. Just put in the href="http://thelinkyouwant.com/page.html" to make it work.
IchBin™        TinyPortal

gamerhookup

Quote from: IchBin™ on August 20, 2008, 05:22:01 PM
Quote from: gamerhookup on August 19, 2008, 11:20:14 PM
Ok thanks man... The page 6 line worked, but not the forum topic 22 you supplied., So I tried a few other things and so far nothing, So the page 6 fromt he articles section works 100 percent and the button is lit..

Here is what I have so you can tell me if I missed up or am missing something else...


Template action:

if (isset($_GET['page']) && $_GET['page'] == 6)    $current_action = 'page6';if (isset($_GET['topic']) && $_GET['topic'] == 22)    $current_action = 'topic=22.msg98';

if ($context['current_action'] == 'aboutus')
$current_action = 'page6';

if ($context['current_action'] == 'guildhistory')
$current_action = 'topic=22.msg98';


button area:

// Show the [aboutus] button.
echo ($current_action=='page6' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'page6' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?page=6">' , $txt[2000] , '</a>
</td>' , $current_action == 'page6' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Show the [guildhistory] button.
echo ($current_action=='topic=22.msg98' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'topic=22.msg98' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?topic=22.msg98">' , $txt[2001] , '</a>
</td>' , $current_action == 'topic=22.msg98' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


K, there ya go, any ideas or did I enter something wrong, keep in mind I only added the .msg98 to the topic 22 since it did not work and that is the action link it is trying to pull...

UPDATE:

I forgot a few of the current actions, no matter still not worked, so i took out all the ms98 to the topic 22 and still nothing, the forum lites up no matter what...(since that is where it is)

If you or we can not fix it, i will just enter a new article and go that route since the about page works now. Inless there is a mod out there that is better..

Thanks for your help!!!!!!

$current_action = 'topic=22.msg98'; needs to be $current_action = 'topic22'; at the top.

The button code should look like this:
   // Show the [guildhistory] button.
   echo ($current_action=='topic22' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'topic22' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?topic=22.msg98">' , $txt[2001] , '</a>
            </td>' , $current_action == 'topic22' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


Ok well i tried all that.. and still it only lites up the forum button... Guess I will just re-do it in the article seciton since you got that working for me...

Thanks anyhow, at least the other is working perfect..
THANKS!

IchBin™

It should work. If you post the code you have I can take another look.
IchBin™        TinyPortal

gamerhookup

K, well her eis the code for that line... A button does lite, it is the forum lite. Just not this lite. No big deal in the end, I think we are just going to do an article since the other one you worked on works. But if you can figure this one out, then were good with that.


if ($context['current_action'] == 'topic22')
$current_action = 'topic22';





// Show the [guildhistory] button.
echo ($current_action=='topic22' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'topic22' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?topic=22">' , $txt[2001] , '</a>
</td>' , $current_action == 'topic22' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

the gaffer

#492
Hey all.

Been trawling through this section as a guest for a few days now... tried countless methods, but had no joy at all.

The theme I am using doesn't seem to include a tag for 'forum'... something I've encountered on several. As a short-term solution I've added a menu block via TinyPortal to allow users to get there, but Ideally I'd like it to be a part of the nav bar.

Now, I have successfully added the 'blog' option to that bar using the tutorial described, which is great, and working like a charm.

However, the 'forum' and 'gallery' options just won't appear for me.

The Gallery option is a freshly installed mod.

Forum is of course bulit in to SMF.

Any ideas what could be causing the issue?

Code below      $current_action = 'admin';
   if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'blog', 'forum')))
      $current_action = $context['current_action'];
   if ($context['current_action'] == 'search2')
      $current_action = 'search';
   if ($context['current_action'] == 'theme')
      $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';


   // Are we using right-to-left orientation?
   if ($context['right_to_left'])
   {
      $first = 'last';
      $last = 'first';
   }
   else
   {
      $first = 'first';
      $last = 'last';
   }

   // Start of the tab section.
echo '
   <ul>';
   
   // Show the default [home] button.
   echo ($current_action=='home' || $context['browser']['is_ie4']) ? '' : '' , '
   <li class="' , $current_action == 'home' ? 'current' : '' , '"><a href="', $scripturl, '">' , $txt[103] , '</a></li>';
     
   // Show the [help] button.
   echo ($current_action=='help' || $context['browser']['is_ie4']) ? '' : '' , '
   <li class="' , $current_action == 'help' ? 'current' : '' , '"><a href="', $scripturl, '?action=help">' , $txt[119] , '</a></li>';

   // How about the [search] button?
   if ($context['allow_search'])
      echo ($current_action=='search' || $context['browser']['is_ie4']) ? '' : '' , '
      <li class="' , $current_action == 'search' ? 'current' : '' , '"><a href="', $scripturl, '?action=search">' , $txt[182] , '</a></li>';

   // Is the user allowed to administrate at all? ([admin])
   if ($context['allow_admin'])
      echo ($current_action=='admin' || $context['browser']['is_ie4']) ? '' : '' , '
      <li class="' , $current_action == 'admin' ? 'current' : '' , '"><a href="', $scripturl, '?action=admin">' , $txt[2] , '</a></li>';

   // Edit Profile... [profile]
   if ($context['allow_edit_profile'])
      echo ($current_action=='profile' || $context['browser']['is_ie4']) ? '' : '' , '
      <li class="' , $current_action == 'profile' ? 'current' : '' , '"><a href="', $scripturl, '?action=profile">' , $txt[79] , '</a></li>';

  // Show the [blog] button.
   echo ($current_action=='blog' || $context['browser']['is_ie4']) ? '' : '' , '
   <li class="' , $current_action == 'blog' ? 'current' : '' , '"><a href="', $scripturl, '?action=blog">' , $txt[blog] , '</a></li>';[/color][/b]

   // Show the [forum] button.
   echo ($current_action=='forum' || $context['browser']['is_ie4']) ? '' : '' , '
   <li class="' , $current_action == 'forum' ? 'current' : '' , '"><a href="', $scripturl, '?action=forum">' , $txt[forum] , '</a></li>';

the gaffer

Solved. Want an even easier, basic way of adding on to the nav bar?

just go

   // The [forum]
   echo '
   <li><a href="hxxp:www.yourwebsite.net/index.php?action=forum [nonactive]">forum</a></li>';

and BAM! It's in there.

Quick, easy, and painless.... Ugh!

IchBin™

Quote from: the gaffer on August 28, 2008, 11:15:07 PM
Solved. Want an even easier, basic way of adding on to the nav bar?

just go

   // The [forum]
   echo '
   <li><a href="http://www.yourwebsite.net/index.php?action=forum">forum</a></li>';

and BAM! It's in there.

Quick, easy, and painless.... Ugh!

That only works on your custom theme. It doesn't apply to the default theme, which this topic is referring to.
IchBin™        TinyPortal

midas

#495
I've just added a Gallery button which links to a Coppermine installation.

The code I used works fine and was added to my used templates' index.template.php; it is placed toward the bottom of the text in between similar looking code of the other buttons that I wish it to display between.  For the benefit of others, the code is:

Quote// The [gallery] button

                 echo ($current_action=='gallery' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'gallery' ? 'active_back' : 'back' , '">
               <a href="http://www.fantasyxtra.com/gallery/index.php">GALLERY</a>
            </td>' , $current_action == 'gallery' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

I also added the button's name "gallery" to the bit of code that can be found by scrolling upwards from the index.template.php page's bottom (it should be above the code for the other buttons) that looks like this:

Quoteif (in_array($context['current_action'], array('blog', 'treasury', 'forum', 'gallery', 'downloads', 'calendar', 'tags', 'search', 'admin', 'profile', 'mlist', 'register', 'login', 'pm', 'spadmin')))

In the last bit of code, notice that the button's name is placed between two of these " ' " and is separated from the next item by one of these " , "For example 'button_name' ,

I'm not a coder, just modified some original code for a button and took the advice of one of the other posters here (the gaffer, thank you but your code only displayed clickable hyperlink text above the buttons).

To adapt the code for your own button, modify your index.template.php by adding the code (to where I described above), then:

  • Edit the word recurrences of "gallery" for the name of your button;
  • Change the "http://www..." (found in this line "<a href="http://www.fantasyxtra.com/gallery/index.php">GALLERY</a>" to reflect the target URL of the button (i.e where you want to take the user when the button is clicked).
  • Change the text in "GALLERY" (in this bit of code ">GALLERY<") to the title you want shown on your own button.
Lastly, add your button's title into your bit of code that looks similar to this code section reproduced below:

Quoteif (in_array($context['current_action'], array('blog', 'forum', 'gallery', 'downloads', 'calendar', 'search', 'admin', 'profile', 'register', 'login', 'pm')))

The button's title must be consistent throughout all the code.  Only change the spelling etc.. for the ">bit between here</a>" as this is how it displays on the menu bar.

(The site referenced above has some adult content so please do not visit unless you are 18 or above and legally mature enough in your location to view said material).
Would be nice to get some traffic around here...

JournalXtra
121GuitarLessons.com

alex30

http://docs.simplemachines.org/index.php?topic=564 -  is this is the only one method of adding tab links?

I read this tutorial and couldn't figure how and where insert URL of a needed page?

-x-Rach-x-

Thank you so much, this is a great and easy to follow tut, even for a newbie like me!!

legend 1234

how do i make it so instead of the url being www.advanced-scape.110mb.com/forum [nofollow] ( which is the default url of the tab ) i can make it like www.simplemachines.com [nofollow] ???

code im using is:



   // Show the [simplemachines] button.
   echo ($current_action=='simplemachines' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'simplemachines' ? 'active_back' : 'back' , '">
               <a href="www.simplemachines.com">Simple machines</a>
            </td>' , $current_action == 'simplemachines' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';



because atm its doing www.advanced-scape.110mb.com/forum/www.simplemachines.com [nofollow]

thanks alot

Gary

That's pretty much it, but it's http://simplemachines.org not .com :P you MUST include the http:// if you're going to include an external link.
Gary M. Gadsdon
Do NOT PM me unless I say so
War of the Simpsons
Bongo Comics Fan Forum
Youtube Let's Plays

^ YT is changing monetisation policy, help reach 1000 sub threshold.

Advertisement: