News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

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

Smythe

ok call me a dummy now but i am a K.I.S.S. kinda guy .... lol could ya show me an example code for linking a tab to an outside site ... also i am wondering do i need a new .gif for the tab or will it generate one ???? i am using a template Aa_New_Damage and i ssse there are .gif pics for the tabs .... you can address the response to "Hey Dummy" lol thanks in advance.

Zarxrax

Ok, I'm stumped with this. I'm using tinyportal and I want to add a link to an article on my tab menu. I got it to shows up and works just fine, but when I click on it, the link doesn't become "selected". It will instead highlight the "home" link. How do I fix this?

bloc

You can't use that routine to check for a "page" or article..it only checks the "action=xxx" in the adress, not the "page=xxx". But tis quite possible to add that too. Depending on what you set as the "hook" - the name for th tab - it can be something like thsi, put AFTER all the others:


// check if a article is active
if(isset($_GET['page']) && $_GET['page']=='mypage')
   $current_action = 'mypage';


Then you just check if $current_action is "mypage" on the tab code. It can also be the ID number of the article, that depends on if you use the shortname for the article or not.

bloc

Quote from: Smythe on June 02, 2007, 03:01:11 AM
ok call me a dummy now but i am a K.I.S.S. kinda guy .... lol could ya show me an example code for linking a tab to an outside site ... also i am wondering do i need a new .gif for the tab or will it generate one ???? i am using a template Aa_New_Damage and i ssse there are .gif pics for the tabs .... you can address the response to "Hey Dummy" lol thanks in advance.

It will generate one - as long as you supply a text for it. :)

And no, the highlight tab won't work for outside link - you can't even see the menu when you follow that link. As long as its internal on the forum you can highlight just about for anything..but not offsite.

viper151

#284
i read all 15 pages and i made this one for my webpage

// Show the [Raid Planner] button...
      echo ($current_action == 'Raid Planner' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'agreement' ? 'active_back' : 'back' , '">
               <a href="http://doureiosippos.servegame.com/PHPraid">Raid Planner</a>
            </td>' , $current_action == 'Raid Planner' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

I didnt used step 1 as you were saying that for external links that wasnt necessary

But(there is always a problem :P )
All is ok except the stylesheet.The button came out like this

as you can see its not core theme but works fine but whats wrong here?
Theme is wow_Dk

HannibalCN

I looked through the topic to see if anyone had asked prior and it doesn't seem as though anyone has.

I'm trying to make the tab only show to specific groups but I'm having no luck.

Any ideas?

IchBin™

Hannibal, you'll have to check for the additional groups. This should check for the group number 2 and display the button if they are in that group.

if (in_array(2$user_info['groups']))
echo 
'your button code here';

If you need to check for more than one group you can add an array to that. This will check for people in groups 1,2,5, and 7.

$mygroups 
= array(1257);
if (
in_array($mygroups$user_info['groups']))
echo 
'your button code here';
IchBin™        TinyPortal

HannibalCN

Is that code for a tab or a button?

IchBin™

You can use it for both. It won't show the tab or the button depending on what you put it around. :)
IchBin™        TinyPortal

viper151


IchBin™

Are you using the default code for the button in that theme? I don't have that theme so I can't check ATM. You should probably post for help in the help topic for that specific theme. Looks to me like your code won't work because of the fact that you don't have actions defined. You'll notice in the button that it says $current_action == 'agreement" or "Raid Planner". These actions have to be defined in your URL for it to work. For instance, you'll notice that when you're in the forum that it says in the URL action=forum. Well if it doesn't say action=agreement or action=Raid_Planner then its not going to work. 
IchBin™        TinyPortal

tonzi

hello guys im trying put an url from the other site? how ima able t0 do this? i tried but  there somethings wrong with the url path

e.g
my site:www.tonzi.com
link site:www.myspace.com

it will turned out as

www.myspace.comhttp://www.tonzi.com/forum/index.php?action=myspace

i wanted to put the url myspace.com alone? pls help ^_^

IchBin™

If you post your code we can show you what to change.
IchBin™        TinyPortal

tonzi

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

Gary

change www. myspace.com/' , $scripturl' , ?action=myspace to http://myspace.com/your-myspace-name-here

-ALM
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.

tonzi

thanks! haha i forgot that http thing in ahref  thank you very much

god_made_me_do_it

Sorry, look, I'm completely new to this, and I can't get that original tutorial to work at all, well, on new themes anyway - which there's no real support for, I just keep getting sent back to this thread by mods - I've basically been tearing my hair out for the past 2 days trying to get a simple 'gallery' button on my themes (PnPn and Musiconica mainly).

My problem arises here where the whole thing gets a bit vague if you're a newbie -

Quote2. In the same file

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



$current_action=='home' - is what sets the tab for the current actions.  As you can see it is defined in 3 instances.  You will need to change it for all three of them.
' , $txt[103] , ' - is the text string that 'Home'.  As you see the variable is insde ' , , '.  The reason for this is because it's inside an echo.  If you are going to hard code the name in the menu you do not need to put ' , , ' around it.

This is how it should look with the made changes.

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


If you want to be neat about it and add support for other languages add this string to /Themes/default/languages/index.english.php and to any other language file that you want to add it to.  ie. /Themes/default/languages/index.{language}.php and change Chat to the translated string.
$txt['chat'] = 'Chat';

I mean, am I supposed to modify this code so it says 'gallery' instead of 'home', or add the edited code underneath? Also -

Quote' , $txt[103] , ' - is the text string that 'Home'.

Dosen't make any grammatical sense, I haven't a clue what that bit's talking about, let alone whereabouts in the file that text string is that it's referring to, what relevance it has to what I'm trying to do or what - I just don't get it  :'( Please someone help then I can stop asking stupid questions and get on with sorting out my forum.

codenaught

#297
Basically you would find the first bit of code it mentions with the "Show the [home] button." code. Then you copy the chat code given there underneath that.

At this point you can edit the attributes of the copied chat button code to suit your needs.

I color coded some of the code:

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

The blue you would change with the web address you want the link to take you to. The red is the text that will show up in the main menu.

Quote' , $txt[103] , ' - is the text string that 'Home'.
Should say is the text string that prints 'Home' on the main menu.
I fixed it on the one in the Online Manual. As for the one in this topic, I'm just leaving it there because I would rather not maintain both and there is a link to the updated version anyway. ;)
Dev Consultant
Former SMF Doc Coordinator

joh87swe

I follow these steps, the new button work but when I click on it, the button still be the same and it's the home button who change. (I use tiny portal). Anyone know why it's not working for me?

IchBin™

What is the link? Does it have an action? For instance, the forum link has action=forum on the end of the URL. Does your link have an action?
IchBin™        TinyPortal

Advertisement: