News:

Wondering if this will always be free?  See why free is better.

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

FlashUK1983

That IS the code I'm using.
substituted the word chat for the word frontpage and altered the url for the url of my frontpage.
but if it helps here's what I did...

Found if ($context['current_action'] == 'search2')
$current_action = 'search';

added after   if ($context['current_action'] == 'frontpage')
      $current_action = 'frontpage';


found // Show the [home] button.
added before       // Show the [frontpage] button.
       echo ($current_action=='frontpage' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
                               <td valign="top" class="maintab_' , $current_action == 'frontpage' ? 'active_back' : 'back' , '">
                                       <a href="http://www.flashuk1983.byethost4.com">frontpage</a>
                               </td>' , $current_action == 'frontpage' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';



It does exactly what it says it should, and adds a new tab, but I don't know how to make the tab visibly active (ie. change colour while on that page)

IchBin™

You can't really do it that way. $current_action is equal to the url in SMF where it says "action=forum" or "action=profile". If your page does not put the action in the URL you cannot use $current_action like you have done.

You will have to assign $current_action='frontpage'; by doing some custom coding. However, I'm not sure it will work since your custom page lives at /index.php and your forum lives at forum/index.php.
IchBin™        TinyPortal

unrelenting

FlashUK1983, try it without the


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


I set mine up a long time ago and just looked it over. It doesn't have that line but it does have the button code and it works as it should.

FlashUK1983

Thanks for trying, but that didn't work.

IchBin™

Ok, I will try to explain how this works so that maybe some of you will understand why it's "not" working for you.

$current_action is what is grabbed from the URL. When you look at your URL throughout the forum you will see at certain points that action=pm, aciton=profile, or action=admin etc. action is what $current_action is set to. So, if you are on a page like your viewing boards board=1.0 or a topic where topic=586 in the URL. You will notice that the home button is always highlighted. This is because in the template_menu function there is no check for board or topic in the URL. There is ONLY checks for $current_action (action in the URL). So naturally, you need to ask yourself "How can I detect the current page that I'm on so I can highlight the button?". What can you check in the URL?

FlashUK1983, your page isn't even inside SMF since its at a different URL. Going to be hard to tell you how it should work if you don't show us how you're doing your "frontpage".
IchBin™        TinyPortal

FlashUK1983

Quote from: IchBin™ on May 22, 2009, 03:18:52 PM
FlashUK1983, your page isn't even inside SMF since its at a different URL. Going to be hard to tell you how it should work if you don't show us how you're doing your "frontpage".

I understand everything before this, but I don't understand what you meant by "How you're doing your "frontpage"."

TerryMullins

I think that he meant, how you are using the 'outside page', outside of SMF.

Terry

FlashUK1983

Aaaah, simple

URL -
       ->forum->forum /smf folders and info
       ->index.php (AKA "frontpage")

IchBin™

Are you using a mod to make the frontpage, or is it just a PHP page? Can you post the code for that page?
IchBin™        TinyPortal

FlashUK1983

It's just a PHP page.

<?php 

$ssi_theme 
0;
$ssi_layers = array('main');
require(
"MYPAGEURL/forum/SSI.php"); 
?>


<HTML>
<center>
THIS PAGE IS STILL UNDER CONSTRUCTION,<br>
PLEASE TRY AGAIN AT A LATER DATE<br>
<img src="URL">
</center>


</HTML>

IchBin™

And since you're not using the default theme that this topic is referring to, can you post the code to your template_menu function too please?
IchBin™        TinyPortal

FlashUK1983

I am using the default theme.

I have admin set to use the default theme and I test everything on that first.
All of my members and guests are defaulted to a different theme.

sorry if I'm clutching at straws here, but would it be possible to use a code which says along the lines of "If Url = ?????????? then highlight this tab".

After scanning through the current code I'm using, it seems to be doing that now, but saying"If action=" instead.


IchBin™

You might try setting in your custom page $current_action = 'frontpage'; and see if that changes it. If not, I'm not sure how to get it to work then since you are using a page that is outside of SMF.
IchBin™        TinyPortal

FlashUK1983

Just thought I'd drop by and let you know, I've solved my problem.

Instead of using
   if ($context['current_action'] == 'frontpage')
      $current_action = 'frontpage';


I used the following instead

        if ($_SERVER['REQUEST_URI']=='/')
$current_action = 'frontpage';




Thank you to everyone who tried to help me.

TerryMullins

I just went to your page and tried it clicked on 'Frontpage' but it did not work as you wanted it to.

I tried again and got:
Template Parse Error!
It seems something has gone sour on the forum with the template system. This problem should only be temporary, so please come back later and try again. If you continue to see this message, please contact the administrator.

You can also try refreshing this page.

Terry

FlashUK1983

The errors you see are because I am currently setting up the other themes.
If you try it now, while the default theme is active, you will see it in action.

TerryMullins

I tried again and your page displays except that the 'frontpage' is not highlighted when you are on the frontpage.

Have you looked into tinyportal ?  It looks to me like it might work for what you're trying to do.

Terry

TerryMullins

It most certainly does work.
Job well done... I will have to make a note of this for the future..

Terry

FlashUK1983

Thank you.

I'm having a little trouble transferring it over to my other themes, but I'm working on that now.
I think there may be a small piece of coding I've missed somewhere

FlashUK1983

#559
OK, so to add a tab for a page outside of the forum, but still using the forum theme from the SSI.php (click here for help on SSI.php)

find$current_action = 'home';

add after  ($_SERVER['REQUEST_URI'], '/')
$current_action = 'chat';


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

add after  // 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="http://www.mysite.com/chat.php">chat</a>
            </td>' , $current_action == 'chat' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


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


and change the line <a href="', $scripturl, '">' , $txt[103] , '</a>

to <a href="http://www.mysite.com/forum/index.php">' forum'</a>


I hope this little tutorial is helpful and easy to understand.

Also, this code works fine for the default theme. It may need tweeking in some places for other themes.

Advertisement: