News:

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

Main Menu

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

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

Previous topic - Next topic

JayBachatero

You are using the wrong tutorial.  This is for TABS.  You need the buttons tutorial.
Follow me on Twitter

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

guppy

Hi,

I added "News" to my RC2 template but it doesn't highlight the active tabs.. Pls help. Here are the codes:


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

// Add own buttons
if ($context['current_action'] == 'news')
$current_action = 'news';

....

echo '
<td class="maintab_' , $first , '">&nbsp;</td>';

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

// Show the [news] button.
echo ($current_action=='news' || $context['browser']['is_ie4']) ? '<td class="maintab_active_first">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action=='news' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?cat=22">' , $txt['menu_news'] , '</a>
</td>' , $current_action=='news' ? '<td class="maintab_active_last">&nbsp;</td>' : '';

if($settings['TPortal_front_type']!='boardindex')
// Show the [forum] button.
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, '?action=forum">' , $txt['menu_forum'] , '</a>
</td>' , $current_action=='forum' ? '<td class="maintab_active_last">&nbsp;</td>' : '';

....

JayBachatero

Change this

// Add own buttons
if ($context['current_action'] == 'news')
$current_action = 'news';


To this

// Add own buttons
if (isset($_REQUEST['cat']) && $_REQUEST['cat'] == 22)
$current_action = 'news';
Follow me on Twitter

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

guppy

Ok it's working thanks  ;)

Hmm.. When do i use which code?

JayBachatero

If you have a regular action=hello you use $context['current_action'].  If not then you use the way that I showed you.
Follow me on Twitter

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

guppy


PuLsE_007

In the words of Comic Book Guy..."Worst Tutorial EVER!" Well, Comic Book Guy's wrong because this was the BEST tutorial EVER! Great job, very well written, EXTREMELY helpful, THANK YOU!  :D

vdubbia

I successfully added a tab to link to an external gmail link (will eventually link to my gmail hosted email).  The link opens the page in the same window.  How do I make it so it will open in a new window?

Here is the code for my tab.. I copied the text for my 'help' button.  This code works, but I don't know if I have the completely correct code, but here it is:

// Show the [mail] button.
   echo '<li><a' , $current_action == 'mail' ? ' class="active"' : '', ' href="http://www.gmail.com"', $scripturl, '?action=help">' , $txt[120] , '</a></li>';

not sure if the action parts are correct, but they seem to work this way...

Appreciate the help!  And if I want a small envelope graphic to appear in the tab, I can use img src, correct?

vdubbia

Quote from: wowzer on June 29, 2006, 11:21:59 PM
I successfully added a tab to link to an external gmail link (will eventually link to my gmail hosted email).  The link opens the page in the same window.  How do I make it so it will open in a new window?

Here is the code for my tab.. I copied the text for my 'help' button.  This code works, but I don't know if I have the completely correct code, but here it is:

// Show the [mail] button.
   echo '<li><a' , $current_action == 'mail' ? ' class="active"' : '', ' href="http://www.gmail.com"', $scripturl, '?action=help">' , $txt[120] , '</a></li>';

not sure if the action parts are correct, but they seem to work this way...

Appreciate the help!  And if I want a small envelope graphic to appear in the tab, I can use img src, correct?

Anyone?

medy

Hi everyone!

it is very nice to see such a good support on this topic. Thumbs up ;)

I'm using SMF 1.1rc2 and Tiny Portal 8.6, default theme.
I added another tab to main menu, which points to article written in TP. I found that this would be the simplest way to link simple text (HTML) file to main tabs. The only problem I found is, that i don't get visited effect on newly created tabs, since it is part of TP and it is external link.

Had anyone similar issues and solved them?

working tab code:// Show the [pomoč;] button...
      echo ($current_action == 'pomoč;' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'pomoč;' ? 'active_back' : 'back' , '">
               <a href="http://www.e-participacija.si/forum_EU/index.php?page=17">Pomoč</a>
            </td>' , $current_action == 'Pomoč;' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


URL, where you can check the tab (it is called "pomoč" - last one in the row): http://www.e-participacija.si/forum_EU/

All well to you :)

JayBachatero

Follow me on Twitter

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

vdubbia

Quote from: JayBachatero on July 02, 2006, 01:12:58 AM
wowzer add target="_blank" to the <a href> tag.

medy the same thing applies as this.
http://www.simplemachines.org/community/index.php?topic=63203.msg619619#msg619619

like this?

// Show the [mail] button.
   echo '<li><a' , $current_action == 'mail' ? ' class="active"' : '', ' href="http://www.gmail.com"', $scripturl, '?action=help">' , ' target="_blank"', $txt[120] , '</a></li>';

and do I need the action=help any more?  do I change that to 'mail'?

JayBachatero


// Show the [mail] button.
   echo '<li><a' , $current_action == 'mail' ? ' class="active"' : '', ' href="http://www.gmail.com" target="_blank>' , ' "', $txt[120] , '</a></li>';
Follow me on Twitter

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

Figueira

Hi!  I have a problem kind of like medy. Using SMF RC2 with tiny portal
i've checked this example you told medy to see, but I could'nt use in my case.

I've created a download, wich is provided by tinyportal action tpmod;dl=0  button here: hxxp:www.lei-forum.com [nonactive], and it does't get the visited effect. Here it goes.

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


and later down:

//The [Downloads]
//if ($context['user']['is_logged'])
                echo ($current_action=='downloads' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'downloads' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=tpmod;dl=0">', $txt['downloads'], '</a>
</td>' , $current_action == 'downloads' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';



Thanks for the attention =)

Figueira

bah! dumb :P somehow I missed jbysmith post!

It's ok now =) thanks anyway


guppy

Quote from: Jay The Code Monkey on June 21, 2006, 02:02:22 PM

// Add own buttons
if (isset($_REQUEST['cat']) && $_REQUEST['cat'] == 22)
$current_action = 'news';


I change cat to page for a Tiny Portal mod article. If I have many many pages under that tab, is it possible to form an array instead of repeating this code? Thanks  :)

JayBachatero

if (in_array(@$_REQUEST['cat'], array(1, 2, 33, 22, 'and', 'so', 'on')))
$current_action = 'news';
Follow me on Twitter

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

guppy


nipun_jain

I am using SMF 1.1 RC2 with TinyPortal. Recently I added felblog module to my site and hence tried to add a blog tab. I edited the code as follows:


Added this code:
if ($context['current_action'] == 'tpmod;blog')
$current_action = 'felblog';


and this one:
// Show the [blog] button.
echo ($current_action == 'felblog' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td class="maintab_' , $current_action == 'felblog' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=tpmod;blog">Blog</a>
</td>' , $current_action == 'felblog' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


But when I click on the Blog tab, the page that opens has the visited effect on the Home tab instead of the Blog tab. What am I doing wrong?

JayBachatero

#179
Change

if ($context['current_action'] == 'tpmod;blog')
$current_action = 'felblog';

To

if ($context['current_action'] == 'tpmod' && isset($_REQUEST['blog']))
$current_action = 'felblog';


That should work.
Follow me on Twitter

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

Advertisement: