News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Adding Top menu Tabs

Started by BizBink, January 28, 2011, 01:03:31 PM

Previous topic - Next topic

Matthew K.

If you want to shoot me a PM with FTP access and a test admin account, I can fix it for you within 5 minutes. It seems as if something was not saved that I added.

BizBink

That would be a huge security risk for me... But I'll consider it since Iv done it before, do you know exactly what you need to do or you think you know or you don't know or you know what it is when you see it (there's alot of or there lol)

Matthew K.

Basically, I would just look at the Subs.php on the server, and Modifications.english.php, in addition to looking into whether you have UTF-8 or not. Things you could do, but I could do within a couple of minutes and have it up. It's completely up to you.

BizBink

Alright but I also want you to pm me after you done

Matthew K.


BizBink

I sent you the pm with extra info

Matthew K.

There you go. The changes I made in Subs.php were not completed...so I just redid them on your file. Out of FTP, and deleted PM with the login information for it.

BizBink

Ok thankyou, I'm going to look at the subs because I'm wondering what I did wrong lol

Matthew K.

It just wasn't updated with the file I gave you. Basically, $txt is a variable, so you were calling a non-existent variable "$txt['Products']".

So, I added a text string to Modifications.english.php by adding the following:

// Products
$txt['products'] = 'Products';
// End Products

And then changing the uppercase P to a lowercase p. And then I also changed a direct link to include $scripturl as it's a habit of mine and a better practice. Pretty simple.

BizBink

No since it's still sorta on the same topic... How would I add sub menus under that products tab... I want to list all if the products in that and have a better description of them

And back to the last prob... So the problem for me was that I had it as an uppercase and it wasn't in the language... And also what do u mean by the txt variable :S

Matthew K.

Take a peak at how another button adds sub-buttons.
'profile' => array(
'title' => $txt['profile'],
'href' => $scripturl . '?action=profile',
'show' => $context['allow_edit_profile'],
'sub_buttons' => array(
'summary' => array(
'title' => $txt['summary'],
'href' => $scripturl . '?action=profile',
'show' => true,
),
'account' => array(
'title' => $txt['account'],
'href' => $scripturl . '?action=profile;area=account',
'show' => allowedTo(array('profile_identity_any', 'profile_identity_own', 'manage_membergroups')),
),
'profile' => array(
'title' => $txt['forumprofile'],
'href' => $scripturl . '?action=profile;area=forumprofile',
'show' => allowedTo(array('profile_extra_any', 'profile_extra_own')),
'is_last' => true,
),
),
),

In this case, for show just put true.

And yes. Don't worry about what a variable is...it's really just a placeholder.

BizBink

So what your saying is that all I do is add another button like it looks like there but I would change the show to true and write another button underneath Seems simple but its propubly not.... Now this I know not all themes support, how would I know if it does or not

Matthew K.

All themes support the buttons...it's just whether the theme has added support for sub-buttons or not. Check out index.template.php template_menu() I believe.

Here's an example.
         'products' => array(
            'title' => $txt['products'],
            'href' => $scripturl . '?page=products',
            'show' => true,
            'sub_buttons' => array(
               'sub_one' => array(
                  'title' => $txt['string_one'],
                  'href' => $scripturl . '?page=whatever',
                  'show' => true,
               ),
               'sub_two' => array(
                  'title' => $txt['string_two'],
                  'href' => $scripturl . '?page=whatever_two',
                  'show' => true,
               ),
            ),
         ),
and so fourth. Then you'd need to add each $txt['']; string to Modifications.english.php.

BizBink

You said alot of things there and they jumped around alot.. Can you say that step by step

Matthew K.

Quote from: Labradoodle-360 on January 28, 2011, 03:50:18 PM
To find out if your theme support sub-buttons, the fastest way would be to ask the theme author in the themes support topic, or if you can dig through some code, look in your themes index.template.php. Although it should be fairly obvious if a theme supports dropdowns or not. (Just mouse over Admin or Profile.)
All themes support the buttons...it's just whether the theme has added support for sub-buttons or not. Check out index.template.php template_menu() I believe.


This is how you add sub-buttons.


Here's an example.
         'products' => array(
            'title' => $txt['products'],
            'href' => $scripturl . '?page=products',
            'show' => true,
            'sub_buttons' => array(
               'sub_one' => array(
                  'title' => $txt['string_one'],
                  'href' => $scripturl . '?page=whatever',
                  'show' => true,
               ),
               'sub_two' => array(
                  'title' => $txt['string_two'],
                  'href' => $scripturl . '?page=whatever_two',
                  'show' => true,
               ),
            ),
         ),



This is how you add the text for each button.

and so fourth. Then you'd need to add each $txt['']; string to Modifications.english.php.

BizBink

Ok thanks... I'll take a look at that and see later on and get back later on if it works or not

BizBink

right now im just wondering if whati have is right (i kno wi havent filld in the blanks of course yet) i havent uploaded it yet but when i di dto see if it was good or not it gave me a error that line 4010 is wrong... idk if thats because i didnt write anything there or its somthing else

please just tell me if i have the template of it right

NOTE: this is the error im getting now
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\Hosting\7285130\html\forum\Sources\Subs.php on line 4010

Matthew K.

Sorry for such a long delay, I was at a retreat for the weekend and only reviewed a couple of topics during the time.

There are quite a few things wrong with that...here is the correct file.

BizBink

Oh don't worry about it, your helping people so no one should expect things from you. Thank you I'm takin a look at it and uploading it now, I'll tell u if it works.

BizBink

well i guess my theme doesnt support submenus :( oh well thanks anyway

but is there a way i can make the theme support it

Advertisement: