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

jeff_ddaz

hey all, noob here....I've referenced http://www.smfthemes.org/index.php?topic=177.0 [nofollow] for adding a new tab. I've yet to try it, however, i need to add my own image to it....I'm using the extreme6 theme and love how he did the main menu, but I'd like to add "New Posts" to it and remove "show unread posts since last visit". please see the link below, I'd like to add the "New Posts" next to the "Home" tab. I've created the image that will be in there, how can I implement this change?

http://www.desertdiamondsaz.com/forum_beta/ [nofollow]

Xarcell

It's not that hard to do, but this is the wrong topic.

There is instructions for adding tabs to the main menu in another thread for SMF 2.0. Try searching for it. This thread instructs for 1.1.x, which won't help you.

jeff_ddaz

oh ok, will do...just saw a link in a prev post about 2.0

Gary

Since people seem to be getting a little confused with which version this is for, which is understandable, I've edited the topic title to indicate that this is for 1.1
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.

Xarcell

Quote from: Gazmanafc on December 08, 2008, 07:32:03 PM
Since people seem to be getting a little confused with which version this is for, which is understandable, I've edited the topic title to indicate that this is for 1.1

Thanks.

flamechica

Ok, I am a little confused too....I want to add a tab to the top of my theme (which isn't a default theme) and want it to go to an external location. I followed the instructions in this tutorial. The tab shows up but it is blue (which doesn't match the theme I am using) and it is pushed all the way over to the right hand side of the screen which pushes all the rest of the tabs to the top of the screen and makes the just plain links. I don't get it.

If this is the wrong tutorial, could someone point me to one that will help me?

Tyrsson

Which version of SMF are you using?

Also depending on how you coded it it is more than likely calling the default tab image.
PM at your own risk, some I answer, if they are interesting, some I ignore.

flamechica

I'm using SMF 1.1.7

Here is my code

// 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')))
      $current_action = $context['current_action'];
   if ($context['current_action'] == 'search2')
      $current_action = 'search';      if ($context['current_action'] == 'chat')
      $current_action = 'chat';
   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 '';

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

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

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

      // Show the [chat] button.
if ($context['user']['is_logged'])
   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://rsdlaughter.shoutmix.net/">Chat</a>
            </td>' , $current_action == 'chat' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';   

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

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

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

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

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


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


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


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

   // The end of tab section.
   echo '';

}

Tyrsson

I think this will be an easier solution for you :)

1. Remove the code that you added in the edit above so that the file is in its original form.

2. Make a backup of the file so that you will have a good copy :)

3.Install this mod:

Custom Tab

4. If it does not show in your theme simply look to the manual install instructions and edit the files that are referenced in the install instructions and present in your custom theme.

The advantage of this mod is that you can change the link through the adminCp with no additional edits once its installed :)
PM at your own risk, some I answer, if they are interesting, some I ignore.

flamechica

Tyrsson,
Thanks a ton. That worked like a charm!

Tyrsson

PM at your own risk, some I answer, if they are interesting, some I ignore.

LSPdznr

I'm running into a similar issue. I've created a custom theme and added new tabs. Unfortunately, that code was added in an older version. When I updated to 1.1.7, the code no longer seems to work. Here is the code:
// 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('treasury','staff','links','contact','search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm')))
      $current_action = $context['current_action'];
   if ($context['current_action'] == 'search2')
      $current_action = 'search';

   if ($context['current_action'] == 'newsandevents')
          $current_action = 'newsandevents';
   
    if ($context['current_action'] == 'scholarships')
          $current_action = 'scholarships';
   
    if ($context['current_action'] == 'history')
          $current_action = 'history';

    if ($context['current_action'] == 'photos')
          $current_action = 'discussions';

    if ($context['current_action'] == 'discussions')
          $current_action = 'discussions';
   
    if ($context['current_action'] == 'aboutus')
          $current_action = 'aboutus';
   
    if ($context['current_action'] == 'shop')
          $current_action = 'shop';
   
    if ($context['current_action'] == 'links')
          $current_action = 'links';

    if ($context['current_action'] == 'home')
          $current_action = 'home';
   
       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']=='mgallery')
          $current_action = 'mgallery';
       if ($context['current_action'] == 'theme')
          $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
   
       if (in_array($context['current_action'], array('blogControlPanel', 'blogs')) || !empty($context['current_blog']))
          $current_action = 'blog';

   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']=='mgallery')
      $current_action = 'mgallery';
   if ($context['current_action'] == 'theme')
      $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';

   if (in_array($context['current_action'], array('blogControlPanel', 'blogs')) || !empty($context['current_blog']))
      $current_action = 'blog';

   // Are we using right-to-left orientation?
   if ($context['right_to_left'])
   {
      $first = 'last';
      $last = 'first';
   }
   else
   {
      $first = 'first';
      $last = 'last';
     
   // are we viewing a page in the blogging community?
   if (!empty($context['zc']['show_zc_nav']) && !empty($context['blog_community']))
      $current_action = 'zc';
   }

   // Show the [News & Events] button.
       echo ($current_action=='newsandevents' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'newsandevents' ? 'active_back' : 'back' , '">
                   <a href="/index.php?blog=6.0"><strong>News & Events</strong></a>
                </td>' , $current_action == 'newsandevents' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
       
       // Show the [Scholarships] button.
       echo ($current_action=='scholarships' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'scholarships' ? 'active_back' : 'back' , '">
                   <a href="/index.php?blog=8.0"><strong>Scholarships</strong></a>
                </td>' , $current_action == 'scholarships' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
   
       // Show the [History] button.
       echo ($current_action=='history' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'history' ? 'active_back' : 'back' , '">
                   <a href="/index.php?blog=7.0"><strong>History</strong></a>
                </td>' , $current_action == 'history' ? '<td class="maintab_active_' . $last . '"> </td>' : '';

       // Show the [Photos] button.
       echo ($current_action=='photos' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'photos' ? 'active_back' : 'back' , '">
                   <a href="/index.php?action=mgallery"><strong>Photos</strong></a>
                </td>' , $current_action == 'photos' ? '<td class="maintab_active_' . $last . '"> </td>' : '';

       // Show the [Discussions] button.
       echo ($current_action=='discussions' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'discussions' ? 'active_back' : 'back' , '">
                   <a href="/index.php?action=forum"><strong>Discussions</strong></a>
                </td>' , $current_action == 'discussions' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
   
       // Show the [About Us] button.
       echo ($current_action=='aboutus' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'aboutus' ? 'active_back' : 'back' , '">
                   <a href="/index.php?cat=16"><strong>About Us</strong></a>
                </td>' , $current_action == 'aboutus' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
   
       // Show the [Shop] button.
       echo ($current_action=='shop' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'shop' ? 'active_back' : 'back' , '">
                   <a href="/index.php?cat=19"><strong><strong>Shop</strong></strong></a>
                </td>' , $current_action == 'shop' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
   
       // Show the [Links] button.
       echo ($current_action=='links' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'links' ? 'active_back' : 'back' , '">
                   <a href="/index.php?action=links"><strong>Links</strong></a>
                </td>' , $current_action == 'links' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
     
   // If the user is a guest, show [login] button.
   if ($context['user']['is_guest'])
      echo ($current_action == 'login' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'login' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?action=login"><strong>' , $txt[34] , '</strong></a>
            </td>' , $current_action == 'login' ? '<td class="maintab_active_' . $last . '"> </td>' : '';


   // If the user is a guest, also show [register] button.
   if ($context['user']['is_guest'])
      echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?action=register">' , $txt[97] , '</a>
            </td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '"> </td>' : '';


   // Otherwise, they might want to [logout]...
   if ($context['user']['is_logged'])
      echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
            </td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '"> </td>' : '';

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

   // The end of tab section.
   echo '
            <td class="maintab_' , $last , '"> </td>
';
// TinyPortal
    if($context['TPortal']['leftbar'])
             echo '<td style="padding-left: 1ex;"><a href="javascript:void(0);" onclick="shrinkHeaderLeftbar(!current_leftbar); return false;"><img id="upshrinkLeftbar" src="', $settings['images_url'], '/', empty($options['collapse_leftbar']) ? 'upshrink.gif' : 'upshrink2.gif', '" alt="*" title="', $txt['upshrink_description'], '" style="margin: 2px 0;" border="0" /></a><img id="upshrinkTempLeftbar" src="', $settings['images_url'], '/blank.gif" alt="" style="margin-right: 0ex;" /></td>';
         if($context['TPortal']['rightbar'])
             echo '<td style="padding-left: 1ex;"><a href="javascript:void(0);" onclick="shrinkHeaderRightbar(!current_rightbar); return false;"><img id="upshrinkRightbar" src="', $settings['images_url'], '/', empty($options['collapse_rightbar']) ? 'upshrink.gif' : 'upshrink2.gif', '" alt="*" title="', $txt['upshrink_description'], '" style="margin: 2px 0;" border="0" /></a><img id="upshrinkTempRightbar" src="', $settings['images_url'], '/blank.gif" alt="" style="margin-right: 0ex;" /></td>';
// TinyPortal end
echo '
         </tr>
      </table>';

}


I know the code is a mess and I want to start over and try the Custom Tab mod but I don't want to revert the entire template. Is there a way to restore that chunk of code to it's original form without reverting the entire page? I didn't save the page before making my changes.

Jago^

#532
Quote from: JayBachatero on March 11, 2006, 02:56:02 PM
He did this on the index.template.php.  On the include part change that to the file you want to include.  Follow the steps to add the tabs.


function template_banner()
{
     
//Load the main_above template.  This is the header part
     
template_main_above();
     
//Load the file needed to be loaded
     
include('banner.txt');
     
//Load the copyright and so on.
     
template_main_below();
}
if (isset(
$_REQUEST['action']) && $_REQUEST['action'] == 'blah')
{
     
//Make use of SMF's layer system
     
$context['template_layers'] = array();
     
$context['sub_template'] = 'banner';
}


Quite an old post, but this is what i'm looking for. I still don't really understand which code should go where though, except for that they all go into index.template.php.
Would it be possible to add this page inside the forum that way (between header/ copyright)? http://www.thepicwhorez.com/irc/tPW_JavaChat.html

edit: http://www.simplemachines.org/community/index.php?topic=286824.0

TerryMullins

#533
I am trying to add a tab to my menu to take me to a new page inside of the smf directory.
The link is for a database that I am creating using dreamweaver cs4.  I am using SSI.php in the page that I am going to... www.fivestarcleaningplus.com/leadgenerationforum/database/index.php [nofollow]

My problem is that if you are logged into the forum and you go directly to the /database/index.php file, everything works correctly with regard to the session information carrying over.
The forum is located at www.fivestarcleaningplus.com/leadgenerationforum/index.php [nofollow]

However, when I follow the instructions that I've read so far, I am able to create a new tab... and when you click on the tab, the correct page loads properly, except that the session gets lost.

I created a user name of : smfuser and password of : smfuser
to gain access and see what I am talking about more clearly...

I would add code to this... but I don't know what code is pertinent...

**  UPDATE : I have been using firefox 3.03 and this problem occurs...
When I use IE 7.06, the page works perfectly with all of the session information working properly.

I found the solution here... http://www.simplemachines.org/community/index.php?topic=285876.msg1877830#msg1877830

Not that this REALLY solves any problems... but it does actually work...



Terry Mullins

FlashUK1983

#534
I have read everypage in this thread, and have noticed alot of people have been having problems with the new tab being the visibly active tab.

I also suffer from this problem, and do not understand any of the solutions given.

My tab is linked to an outside page, but does not change to be the active tab while I am on the outside page. Can anyone help me?

IchBin™

How are you viewing the page in SMF if it is external? Can you show the example links to your forum and your external page?
IchBin™        TinyPortal

FlashUK1983

sorry, I didn't explain that very well.
What I meant was external from the forum folder.

Here is the url:
http://www.flashuk1983.byethost4.com

The tab I have added is the "frontpage" tab

TerryMullins

Flash,

Can you show us the code that you are using for this ?
I'm sure that it must be some small thing that just isn't right there...

Terry

FlashUK1983

Sure, the code I used it plainly here........
http://www.simplemachines.org/community/index.php?topic=63203.0
I've done both steps and tried both versions

TerryMullins

I was referring to the 'actual code' in your page... not the code that was offered for demonstration purposes... :D

If you can post the snippet of code, (that you are trying to make work) here, perhaps we can review it and possibly determine where the problem(s) are...

Advertisement: