SMF Development > Next SMF Discussion

Add menu button function

<< < (5/7) > >>

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".

--- End quote ---

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

Find

--- Code: --- 'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
--- End code ---

Replace

--- Code: --- '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(
),
),
--- End code ---

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):

--- Code: --- '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(
),
),
--- End code ---

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

--- Code: ---'target' => '_blank',
--- End code ---
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...

--- Code: ---'target' => '_blank',
--- End code ---
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 :)

--- End quote ---

Didn't know that. I've always seen it done the "sneaky" way that I pointed out above.

Labradoodle-360:
index.template.php

--- Code: ---<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
--- End code ---

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

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version