another TAB highlight question

Started by deansmar, July 14, 2010, 07:44:02 AM

Previous topic - Next topic

deansmar

sorry folks, i have not found the answer i was looking for in the searches that i have done.

i am running SMF 2-RC3 with SP 2.3.2 on a SMF Default Theme

i have added pages withing SP and assosiated TABs with in the Subs.php for SMF everything works fine.

now i have gone onto the next step;

i have added external URL's to my Menubar (Tabs), this all works fine as well, but the associated Tab in the Menubar does not highlight.


        'test' => array(
        'title' => 'test',
        'href' => 'http://www.xxxx.co.uk/xxx', 'target' => 'newwindow',
        'show' => true,
        'sub_buttons' => array(
                'test1' => array(
                'title' => 'test1',
                'href' => 'http://www.xxxx.co.uk/xxxx/xxx.php', 'target' => 'newwindow',
                'show' => true,
                ),
                'test2' => array(
                'title' => 'test2',
                'href' => 'http://www.xxxx.co.uk/xxxx/xxxx.php', 'target' => 'newwindow',
                'show' => true,
                ),     
         ),
    ),


i know i will have to add another "elseif" in the "if" statment that comes after this line in Subs.php
   // Figure out which action we are doing so we can set the active tab.
   // Default to home.

my problem is, i dont know enough coding to figure out the elseif statment for URL's

i hope someone could give me a clue  ;)

deansmar

have i posted this in the wrong section ??

xenovanis

It's not the wrong board, it's probably the bumping within 24 hours that will make you less popular.

I believe you'll need to define a current action as well, in /Sources/Subs.php, somewhere around these lines


if (isset($context['menu_buttons'][$context['current_action']]))
$current_action = $context['current_action'];
elseif ($context['current_action'] == 'search2')
$current_action = 'search';
elseif ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
elseif ($context['current_action'] == 'register2')
$current_action = 'register';
elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
$current_action = 'login';
elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
$current_action = 'moderate';
"Insanity: doing the same thing over and over again and expecting different results."

deansmar

sorry for the bumping, i`ll take a slap to my hand..

i know i need an action in Subs.php

its a case of what would be the correct coding for the action?

xenovanis

Well, I haven't tried this, but I can imagine it would be something like this:


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


Make a backup of the file and try it?
"Insanity: doing the same thing over and over again and expecting different results."

deansmar

no that would not work.... "Test" is not an action !!

just a name of the Array, and the Array calls a URL not a normal SMF action.

if there was a way to bind the Array into an Action it would work..

but because the "current_action" is not realy an action this code would never work...!! 

Kays

What you need to do is to define $context['current_action'] on the page where SSI.php is included and then check for in Subs.php.

So for xenovanis's test example above you will also need to add the following to the test page.


$contect['current_action'] = 'test';

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

deansmar

the tab goes to an external URL and not an internal URL

i can not add anything to the website that the tab will take you to..

or do you mean that i have to enter the URL in the SSI.php??

Kays

Ok, what do you mean by highlight?

If it's an external site and the menu bar isn't shown, then there's no way or reason to highlight it.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

deansmar

of course the menubar is still shown.. other wise i would not want to highlight it !!

in the example at the top of this post, it shows that i open the URL in a newwindow.

so the original window is still there, with the home tab highlighted insted of the one that was pressed.

all i need it the correct action coding in the Subs.php to highlight the said tab.

for example this code works for SimplePortal pages.


elseif (isset($_REQUEST['page']) && in_array($_REQUEST['page'], array('Page-ID-1', 'Page-ID-2' , 'Page-ID-3' )))
            $current_action = 'Array-ID';

Kays

So the page is not external to your site and the menu bar is shown.

Then do as suggested. On that page add $context['current_action'] = 'this_page'; Then in Subs.php check for it.


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


Change this_page to something appropriate for each page.

Question.

Is this correct? I've not seen target used like that before.


'href' => 'http://www.xxxx.co.uk/xxx', 'target' => 'newwindow',

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

deansmar

QuoteQuestion.
Is this correct? I've not seen target used like that before.

'href' => 'http://www.xxxx.co.uk/xxx';, 'target' => 'newwindow',

it took me a while to get it to work, but this code opens a new window, i dont normaly use the target this way either, but it works in IE8.

back to the problem at hand...
the page is sort of external, its on the same server in a sub domain.

lets say like in this webspace the very top menu bar, the button "Online Manual" takes you to a URL "http://docs.simplemachines.org/" and the button "Online Manual" is highlighted

really all of the buttons on the Top menu bar go to a URL and not an Action.

i find it strange that with this tutorial; 
Adding tabs to SMF 2.0, it does not tell you how to highlight the Tab but Tells you how to make them.

Kays

Yes, the tutorial does miss that. I'll try to update it, but I'm no docs writer.  ::)

Has this resolved your issue or do you still require assistance.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

deansmar

the problem is still there...

because this is calling or checking an action that i can not set..

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

Kays

Why can you not set $contect['current_action'] for that page?

In looking at this:


elseif (isset($_REQUEST['page']) && in_array($_REQUEST['page'], array('Page-ID-1', 'Page-ID-2' , 'Page-ID-3' )))   
            $current_action = 'Array-ID';


Changing Array_id in the last line to test should get it to work with the example in the first post.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

deansmar

that code works for pages from SimplePortal... or manuel installed pages.. i am not calling a page

i am not trying to load a "page" i am loading a URL for external/different domain name

Kays

A url is a page. If SSI.php is included on that page, then you should be able set $context['current_action'] on that page.

The thing is that in order for SMF to highlight a tab. It needs to know which page you are on. Which is what setting $context['current_action'] does. It sets a value which is unique to that page so that can be checked in Subs.php. Another method is check $_REQUEST['action'] or $REQUEST['page'], if it's unique, as SP does.


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

deansmar

understood that...

i can not place SSI on the URL page

must i then declair the URL page in the SMF SSI.php ??

i suppose what i need is a $request['URL']  if thats logical..

Kays

If you are not including SSI.php on that page. How does the menu bar get there? There needs to be some interface with SMF.

What's the url to that page?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

deansmar

the menubar gets there through the <a href> in the buttons array.

      'Shop' => array(
        'title' => 'Online Shop',
        'href' => 'http://www.deansmarine.co.uk/shop', 'target' => 'newwindow',
        'show' => true,
        'sub_buttons' => array(
         ),
    ),


which is also shown in the tutorial for Adding tabs to SMF 2.0

Advertisement: