News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Change SMF 2.1 Beta 2 menu?

Started by PaulKet, November 11, 2015, 03:44:15 PM

Previous topic - Next topic

PaulKet

Can someone please tell me how to change the SMF 2.1 menu? I want to change the current word "home" to "forum" and then add a home link with a URL to a different website. I searched and only found information relevant to SMF 2.0.

Thanks for any help.

Antes


PaulKet

Ok, I found this http://wiki.simplemachines.org/smf/Buttons_-_How_do_I_add_buttons_to_SMF_2.0 and this topic http://www.simplemachines.org/community/index.php?topic=532676.msg3785603#msg3785603 which helped me change my "home" button to the URL where I wanted it to point. I am missing a "forum" button now and do not understand how to add one. What do I add from:

'menu_action' => array(
'title' => 'text for menu',
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
'sub_menu_action' => array(
'title' => 'text for sub-menu',
'href' => $scripturl . '?action=newaction',
'show' => true,
'is_last'=> true,
),
),
),


after

'home' => array(
'title' => $txt['home'],
'href' => 'http://myforum.com',
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),


so my menu will look like: Home | Forum | Search | Admin | etc. ?

Antes

copy the home and paste after the home and edit the parts needs changes.

PaulKet

Quote from: Antes on November 11, 2015, 05:19:10 PM
copy the home and paste after the home and edit the parts needs changes.

So now I have:

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


and I'm getting errors that seem to be from changing 'home' to 'forum', what am I doing wrong? Also, do I need to remove the second instance of:

'is_last' => $context['right_to_left'],

?

Kindred

Well, is the variable string txt['forum'] defined?

And yes, you need to drop that second statement
Сл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."

PaulKet

Quote from: Kindred on November 11, 2015, 11:02:04 PM
Well, is the variable string txt['forum'] defined?

How would I do that? I know nothing about php (I want to learn but know nothing about it now).

lntit

In /themes/<theme>/languages/ there are the php files for text strings like Modifications.english.php.
Write:
txt['forum'] = 'Forum';

PaulKet

Quote from: lntit on November 12, 2015, 07:56:05 AM
In /themes/<theme>/languages/ there are the php files for text strings like Modifications.english.php.
Write:
txt['forum'] = 'Forum';

In my Modifications.english.php file I now have:


<?php
// Version: 2.1 Beta 2; Modifications
txt['forum'] = 'Forum';
?>



It is giving me this error: Parse error:  syntax error, unexpected '=' in .../Themes/default/languages/Modifications.english.php on line 3

Shambles

Try

<?php
// Version: 2.1 Beta 2; Modifications
$txt['forum'] = 'Forum';
?>

PaulKet

#10
Quote from: Shambles on November 12, 2015, 08:50:37 AM
Try

<?php
// Version: 2.1 Beta 2; Modifications
$txt['forum'] = 'Forum';
?>


This worked!  :)

Thank you, Antes, Kindred, lntit and Shambles for your replies.

How can I change the generic question mark icon that appears in the menu next to the word "Forum" to an icon that is more appropriate?

Edit: I got it figured out  :) For anyone else who wants to know, add this to your index.css file:

.generic_icons.forum {
   background-position: -83px -161px;
}

lntit

Oh derp, I really forgot $, lol. My bad. :-[

PaulKet

Quote from: lntit on November 12, 2015, 09:03:33 AM
Oh derp, I really forgot $, lol. My bad. :-[

Your help was appreciated.

Antes

that's bit more complicated, but if you are adding a new menu item and it needs (which it needs) an icon. You need to find an icon (16x16) copy it into your theme's images folder then do this

.generic_icons.forum {background: url(../images/forum.png) no-repeat;}

The numbers you see is the position of the icon inside the sprited set. We strongly suggest our users not to change the default sprite instead create new one or link the images normally.

pajeroid

Where do we add this line?

Quote from: Antes on November 12, 2015, 11:47:56 AM
that's bit more complicated, but if you are adding a new menu item and it needs (which it needs) an icon. You need to find an icon (16x16) copy it into your theme's images folder then do this

.generic_icons.forum {background: url(../images/forum.png) no-repeat;}

The numbers you see is the position of the icon inside the sprited set. We strongly suggest our users not to change the default sprite instead create new one or link the images normally.

Arantor


pajeroid

Quote from: Arantor on November 01, 2019, 11:32:49 AM
In the theme CSS file.

I've added it to the index.css file but no change... when I inspect the element I would like to change I get this....


<li class="button_directory">
<a href="http://www.mywebsite.co.uk/index.php?action=directory">
<span class="main_icons directory"></span><span class="textmenu">Companies</span>
</a>
</li>


It's like the span class section above is overruling the css. Any ideas? It's the Directory mod and displays the help icon.

Arantor

Or the fact that generic_icons was renamed and this is why trying to customise still-in-development software is hard when rules change on you without warning.

pajeroid

I figured it out. I needed to change the button code in Subs.php from:

'directory' => array(
'title' => $txt['directory_text'],
'href' => $scripturl . '?action=directory',
'show' => allowedTo('directory_view'),
'sub_buttons' => array(),


to:

'directory' => array(
'title' => $txt['directory_text'],
'icon' => 'villa.png',
'href' => $scripturl . '?action=directory',
'show' => allowedTo('directory_view'),
'sub_buttons' => array(),


Then place villa.png in my theme images folder and voila!

Advertisement: