News:

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

Main Menu

Add menu button function

Started by lurkalot, April 29, 2010, 01:01:47 PM

Previous topic - Next topic

Oldiesmann

Quote from: timetraveller on October 17, 2011, 05:20:10 AM
Are any of the mods listed here suitable for SMF 2.0.1?

All I'm looking for is to add one button in exactly the same style as existing menu so I can link back to the home page and to rename the current "home" button to "forum".

You don't need a mod to do that. A quick edit to Subs.php will do the trick:

Find
'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),


Replace
'home' => array(
'title' => $txt['home'],
'href' => 'http://www.yoursite.com',
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
'forum' => array(
'title' => 'Forum',
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
),


Or, if you want the "Home" item to open in a new window, you can do this (it's a bit of a cheat, but it works well):
'home' => array(
'title' => $txt['home'],
'href' => 'http://www.yoursite.com" target="_blank"',
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
'forum' => array(
'title' => 'Forum',
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
),
Michael Eshom
Christian Metal Fans

Matthew K.

Oldies - A better way to add a target is like this...

'target' => '_blank',

As "target" is already a variable built into the Menu system.

Also, I should be releasing a Menu Editor Lite system for SMF 2.0.1 around Christmas time :)

Oldiesmann

Quote from: Labradoodle-360 on October 18, 2011, 11:39:29 AM
Oldies - A better way to add a target is like this...

'target' => '_blank',

As "target" is already a variable built into the Menu system.

Also, I should be releasing a Menu Editor Lite system for SMF 2.0.1 around Christmas time :)

Didn't know that. I've always seen it done the "sneaky" way that I pointed out above.
Michael Eshom
Christian Metal Fans

Matthew K.

index.template.php
<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>

timetraveller

Ooh - some coding ..... am I ready to take the plunge??? It looks straightforward .....  :-\

timetraveller

First problem - can't find that bit of code.

Found two files in "Sources" directory. One labelled subs.php  and the other subs.php~

I assume I need subs.php but when I pasted that first bit of code into the search box on TextPad it can't find it.

I'm using SMF 2.0.1 with a colour variant of Curve theme.

Matthew K.

You should open up a new topic for your question in SMF Coding Discussion.

OCJ

Would be useful standalone and ... only a few portals have menu functions as well.

Language Menu
One thing I think should be added automatically to the menu is a language button with submenu items for each added language.
Cant believe how messy it is adding mod code all the time in different themes to get either a language button, drop down or flag. No other software is this bad ... that put me off SMF 5 years ago and it hasn't improved much.

Languages are automatically added in admin so why can't a menu items for them (in a list under languages). When a new (first) language is added a language menu button should be added with that language as a submenu item. Additional added languages being added to the language menu list.




Kindred

Language does not belong in the main menu.....
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Matthew K.

Kindred is right...and it wouldn't be hard to add yourself. $context['languages'] is populated by getLanguages();, call getLanguages(); in the setupMenuContext(); function, and then use a loop to feed the languages into the menu array where you want.

OCJ

Thats the only place that I can think of it working on any template as it is the only thing uniformly displayed on all templates. If there is no other way except editing by hand then it is, as I said - a mess. Other CMS and boards manage it much better I think.

Kindred

There are plenty of better places for it.... and several different ways to get it into those locations.
Language choice does not belong in the main menu.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Matthew K.

Eventually I'll get to updating my Language Dropdown mod, which won't have any template edits. Let's get back on topic here, though.

OCJ

This is the point, if it cant go in the menu it should have some universal positions - or placement like Joomla with a mod position all themes should follow.... haha - fat chance of that.

It should be sorted out some way or other as it puts off ordinary people using smf when they have to place a function call in a template file they know nothing about.
"oh wait a minute what about that semi colon or echo and apostrophe" ...

Even for reasonably savvy people it doesn't work out all the time - shouldn't be that way these days and its holding back smf from what it should be.


utf8  has taken over recently and for good reason - we all need extra languages as we cross borders and languages to share information.

lurkalot

Did the menu manager idea ever get considered as a core feature?  Yes I know it's an old thread, but it's still a relevant question. ;)

Arantor

It got considered, it certainly isn't going to happen in 2.1. Will it happen for 3.0? Probably, but no-one can say for certain right now.

lurkalot

Quote from: Arantor on November 07, 2013, 04:15:47 PM
It got considered, it certainly isn't going to happen in 2.1. Will it happen for 3.0? Probably, but no-one can say for certain right now.

Thanks, I'm more than happy with that answer.  It might not seem like it, but I can guarantee people would love that feature. :)

Advertisement: