News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Add/Edit Menus in 2.0.8

Started by lewism, September 03, 2014, 09:36:56 PM

Previous topic - Next topic

lewism

Lots of leads when searching but strangely, nothing which simply answered this question or, I didn't notice it.

I've been using SMF on and off for many years but haven't touched it in a while so cannot recall how we edit new menu items in. More specifically, I'd like to add a second Link before the large top left menu name.

I would prefer not having to add a module which may or may not get updated as SMF updates but I also don't want to get stuck editing code.

Suggestions would be most welcome.

Thanks.

Kindred

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

mashby

Yeah, either with a mod or a manual edit it should work. I agree with Kindred's suggestion. It's pretty easy to configure/code the menu. :)
Always be a little kinder than necessary.
- James M. Barrie

lewism

Looks to be in the subs.php page?

Any chance you know what the larger top/left Forum Name text section is called? I would like to put a second item right beside that one.

mashby

I have mods installed which affect Subs.php, but maybe that's not relevant to you. :)

Yeah, in Sources/Subs.php, this is the function:
function setupMenuContext()

The link Kindred provided does a great job explaining the method to add your own. The order is determined as you might imagine. First one listed shows up first. :)
Always be a little kinder than necessary.
- James M. Barrie

lewism

Thanks very much guys. Now I can get to work on this :).


mashby

Always be a little kinder than necessary.
- James M. Barrie

lewism

I'm sure it'll go fine, the doc seems to say it all.

Thanks again.

Kindred

but wait...  form your description, you are talking about adding something - not into the menu, but into the header, up with the forum logo/name?   If so, then you would have to code it into the header section of index.template.php for each theme
Сл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."

lewism

Quote from: Kindred on September 04, 2014, 06:14:51 AM
but wait...  form your description, you are talking about adding something - not into the menu, but into the header, up with the forum logo/name?   If so, then you would have to code it into the header section of index.template.php for each theme

LOL, good call. Yes, I just didn't want to keep asking questions now that I had a lead and thought I could figure out the rest. The info I was given does help in that now I can modify the main menu so that was useful anyhow.

However, what I really need to do is to add a 'Main Site' menu item at the very top, right next to the Forum Title.

Kindred

yeah - for that, you will have to edit index.template.php for each and every theme that your site supports.

look for the term "logo" - I think
Сл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."

lewism

And in that file, look for the section which has <h1 class="forumtitle">

<h1 class="forumtitle">
<a href="http://www.somedomain.com/forum/index.php">Some Domain</a>
</h1>

Edit accordingly :)

Kindred

except, in php code, it won't look quite like that, since the url/locations of the logo file would be in php, not typed out html
Сл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."

lewism

In my case, I only needed to add a link for the main site so just added a second URL.
Someone else will do the logo or what ever is needed :)

Hj Ahmad Rasyid Hj Ismail

Or (since like you gonna have a logo in place of the forum name) you can just use this mod to create a custom top menu to link you to main site (or any others): http://custom.simplemachines.org/mods/index.php?mod=2564

Otherwise, you will have to separate the logo from the forum title in this code and create some stylings for them:

<h1 class="forumtitle">
<a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? $context['forum_name'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
</h1>

lewism

I am a little surprised that adding links/menus is not built directly into smf by now. This has been an ongoing desire for many many years :)

Hj Ahmad Rasyid Hj Ismail


lewism

I prefer not using mods because there is no way of knowing when authors abandon them. And of course, that happens a lot.


Kindred

On the other hand, many mods are supported... And many of the "abandoned" mods still have other users supporting them...

In other words, I think your logic of not using mods is flawed...
Сл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."

lewism

You might think it's flawed but I've built countless sites so am not exactly new at this.
In some cases, mods are fine, in some cases, they are not worth the time to be left hanging in the future. I would rather make notes of things I've modded then if an update takes away my mod, I can fix it quickly instead of waiting for some author to get around to it or not.

mashby

I can understand the hesitation for installing mods. However, how many sites out there are running SMF without any mods at all? This site sure has some. But let's say a mod changes all of the letters As into letter Bs. I don't know who would ever write or install such a thing, but stick with it. If the mod author abandoned it, would that mean I would uninstall it? I doubt it. I only have a few mods install on my 2.0.x site and I haven't even looked to see if the mods are abandoned/supported because they all work.

When 2.1 comes out, that's when I have to look at mods and their compatibility with 2.1 to determine if I even upgrade to 2.1 or just stay on 2.0.x. I did the same thing for years on 1.1.x. :)
Always be a little kinder than necessary.
- James M. Barrie

lewism

#21
No hesitation at all. Sometimes, a mod makes sense but for most long term things, I tend to gravitate away from mods for the reasons I've said. In my experience, and I've been at this for a very long time, I have found that it's not worth using mods and that most mods are simply an automated means of editing something or other which a real admin should be able to do manually. Counting on author to keep your production site up is not a great idea unless you are very picky about the mods you pick.

All of that said, I'm not talking only about SMF here, I'm talking about everything along these lines, WP, Joomla, etc etc.

Anyhow, this is a personal choice :)

Arantor


lewism

OLD topic I know but... when making changes to the php code, I assume those are written over when an update is installed?
Just want to confirm.

Running 2.0.9

Thanks.

margarett

It depends :P

If you update via patch (eg: 2.0.8 --> 2.0.9), those changes are kept in place, as the patch is pretty much a MOD that only changes the affected code.
If you do a large upgrade then yes, your changes are lost as the whole file is replaced.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: