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

BizBink

well i know theres a doc for that and i have read it over and over folowed it and came to a conclusion that the script im lookin g for in the defualt them Index.template.php is not on there and look like something different like this

// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<div id="main_menu">
<ul class="dropmenu" id="menu_nav">';

foreach ($context['menu_buttons'] as $act => $button)
{
echo '
<li id="button_', $act, '">
<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';
if (!empty($button['sub_buttons']))
{
echo '
<ul>';

foreach ($button['sub_buttons'] as $childbutton)
{
echo '
<li>
<a href="', $childbutton['href'], '"', isset($childbutton['target']) ? ' target="' . $childbutton['target'] . '"' : '', '>
<span', isset($childbutton['is_last']) ? ' class="last"' : '', '>', $childbutton['title'], !empty($childbutton['sub_buttons']) ? '...' : '', '</span>
</a>';
// 3rd level menus :)
if (!empty($childbutton['sub_buttons']))
{
echo '
<ul>';

foreach ($childbutton['sub_buttons'] as $grandchildbutton)
echo '
<li>
<a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
<span', isset($grandchildbutton['is_last']) ? ' class="last"' : '', '>', $grandchildbutton['title'], '</span>
</a>
</li>';

echo '
</ul>';
}

echo '
</li>';
}
echo '
</ul>';
}
echo '
</li>';
}

echo '
</ul>
</div>';
}



adn theres more after that but i gave enough to get the picture... where do i type in to add another menue tab

Illori

for smf 2.0 to modify the menu you need to look in subs.php not index.template.php.

Kays

Hi, it is done differently in SMF 2.0. This should answer any questions on how it's done.

Adding tabs to SMF 2.0

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

BizBink

ok so i did that all and followed it exactly but now it shows the tab but theres no name for the tab :S

idk if its something eles or if its becasue theres no language for it

Matthew K.

If you want to, attach your Subs.php and Modifications.english.php and then explain what you want to the tab to say, and what you want it's attributes to do and I'll do it for you.

BizBink

where is the Modifications.english.php loacated at

and i just want it to show the name to the tab thats it like it just shows a blank box.... look at it here forum.bizbink.com

BizBink

ummm i dont know where the Modifications.english.php is at but i can attach the subs first for now

i just want it to say the tabs thing and nothing special its just that theres nothing there but a black box

Illori

Themes/default/languages/Modifications.english.php

BizBink

ok here you go and if you want to see what im talking baout here when i say theres nothing there but a blank box look here forum.bizbink.com

Matthew K.


BizBink

Product

but also in the future i want to be able to add sub menus

Matthew K.

Here is your Modifications.english.php.

Also - Out of curiosity, what menu mod do you have installed?

BizBink

something called custom top menu

BizBink

i added it and it still isnt there... still a blank box with no text

Matthew K.

Yeah - That's it...interesting. Did you clear your forums cache?

BizBink

i just did it twice now... any other ideas... does  it im using a another theme thats not defualt

Matthew K.

I don't see how that couldn't be working, I just double checked the code I wrote - And it should be working. Are you using UTF-8? Theme won't affect it.

BizBink


Matthew K.


BizBink

i would have no idea if i am using that or not... this is all new to me so now im thinking is my coding wrong

can you take a look at it... i uploaded it a while ago called subs.php

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

Matthew K.

You could contact the theme author, beyond that it'd be all custom coding on your part.

BizBink

thats to much for me to do, the author will make me have to pay for it and im willing for that, just that im taking a guess its going to be sky rocked price :S. and also i wont be able to do that all myself since i have no experince with coding thats that advanced lol. ill just deal with it for now

Matthew K.

Even if it was something you needed to pay for...which I would think someone could do it for you free, it should be cheap if anything...

BizBink

well how much would you price it for

Matthew K.

I'll look into doing it for you.

BizBink


Matthew K.

Yes, but I have been busy developing. Not sure I'll be able to get to it until tonight. Trying to finish up Stay Connected 1.0.

BizBink

Ya I figured that when you changes your signature to that, alright then, don't worry about PMing me when you start looking at it because I set the FTP account to not delete for 24hrs

And where's ur mod email template editor... Sorta interested in using that since I will be needing to update users :)

Matthew K.

I would appreciate a PM in a couple of hours reminding me, or I may forget. I've been really busy and am extremely exhausted from a long weekend.

Regarding Email Template Editor, at this point, I am considering selling it (cheaply) on another mod site, as I've put a lot of work and time into it.

Advertisement: