Adding A Button Isn't Working For Me

Started by Semetery, July 21, 2014, 11:17:42 PM

Previous topic - Next topic

Semetery

Hello there,

I'm at a loss here trying to add a button to my menu. I use the theme 'Concept', which is amazing! But, probably because I'm still very new to SMF, I'm having the hardest time trying to add a new button to the menu. It's been a menu nightmare thus far. Haha.

I've searched and searched and cannot seem to get it working, clearing the cache and all. I dug through index.template.php and haven't found anything specific and I've added what I thought was the proper code in Subs.php and defined the txt string in Modifications.english.php and it doesn't work, nothing changes at all.

Here's the code I put in index.template
'site' => array(
'title' => $txt['Site'],
'href' => 'http://mysiteurl.com',
'show' => true,
'sub_buttons' => array(
),
),


I put it below this:

'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),


And here's what I put in modifications.english
$txt['site'] = 'Site';

I guess I'm doing something wrong but it isn't working at all, I've seen absolutely no difference since adding the code. Is it a theme specific thing in this case?

Anyone who helps me, I greatly appreciate it, my head is spinning trying to figure out where I'm going wrong. I've tried mods and they either failed during installation (so I didn't install them) or they didn't work at all (for me). Thanks!

Arantor

$txt['site'] isn't the same as $txt['Site']. You have to be precise about this, it's case specific.

If you declare it as $txt['site'] in Modifications.english.php, you need to use $txt['site'] in Subs.php.

Semetery

Thanks for the reply!

I changed Site to site across the board and it still isn't showing up. I cleared the board cache as well as my browser cache. For some reason, I cannot get the menu to change at all. I have no menu related mods installed at all.

Arantor

So to clarify you now have this in Subs.php:
'site' => array(
'title' => $txt['site'],
'href' => 'http://mysiteurl.com',
'show' => true,
'sub_buttons' => array(
),
),


And this in Modifications.english.php:
$txt['site'] = 'Site';

?

Do you have Menu Editor Lite or Menu Editor Pro installed?

Semetery

I have exactly that in Subs.php and in Modifications.english.php I have

$txt['site'] = 'site';

I changed all uppercase S's to lowercase ones to make sure they all match exactly right. It still isn't showing up at all. I, again, cleared my cache as well as the forum's cache. And nope, no menu editor's are installed. The only thing I had installed that had to do with the menu was the 'Remove Help From Menu' mod, I uninstalled it as well before trying all of this.

Sir Osis of Liver

Try this -



'site' => array(
'title' => 'Site',
'href' => 'http://mysiteurl.com',
'show' => true,
'sub_buttons' => array(
),
),


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

@Krash: while that's nice and all, it doesn't solve the problem of why this isn't working - which could also affect other mods down the line.

You didn't have to set it to $txt['site'] = 'site'; the first one is just an identifier. You could just as easily have written $txt['site'] = 'My Cool Site'; and it should work.

So, are you using English and is there an English-UTF8 file lurking in the languages folder too?

Sir Osis of Liver

Just to see if 'title' is the problem.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

Having literally just made a menu button in the mod I'm working on, I can say that it shouldn't be the problem...

Semetery

I tried it and it didn't change anything. I appreciate the help though.

Yes, using English. I checked for any UTF8 files and there weren't any. I checked my themes language folder (just to see, I'm not familiar with the inner workings of SMF very well) and it didn't have anything related to the menu.

The only thing I can think that could be the problem, again I don't know this very well, is that I'm using a custom theme that isn't outputting it perhaps? The theme is 'Concept', for reference if that matters at all.

Arantor


Semetery

I just overlooked it but there are these: Gallery.english-utf8.php, SPortalAdmin.english-utf8.php, SPortalHelp.english-utf8.php

I assume it isn't related they are there. I'm not using any portal, the uninstall had errors so I just disabled it and left it. Could that be the root of my issue perhaps?

And the link is http://midnightspookhouse.com/community/ [nofollow]

Arantor

Right, it's not the theme. I see the reference to 'site' in the theme, which means the raw code in Subs.php is correct.

Which means there's something interesting about it not loading Modifications.english.php properly. Please can you attach the actual file here?

Semetery


Sir Osis of Liver

<sigh>

Just did it in Concept.  Put $txt['site'] = 'Site' in index.english.php.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Semetery

I just did, still didn't change. Mods, like SMF Gallery, seem to have no big issue editing the menu, but I certainly am.

Sir Osis of Liver

Did you try this?




'site' => array(
'title' => 'Site',
'href' => 'http://mysiteurl.com',
'show' => true,
'sub_buttons' => array(
),
),


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Semetery

I did. I tried all four S's lower case and all upper as well. I made the changes in Subs.php, Modifications.english.php and index.english.php.

Something odd I did notice, I removed the mod that initially removed 'Help' from the menu and now 'help' isn't back on the menu.

Arantor

Quote from: Krash on July 21, 2014, 11:51:54 PM
<sigh>

Just did it in Concept.  Put $txt['site'] = 'Site' in index.english.php.


Don't know what you're sighing for. Modifications is the only language file absolutely guaranteed to be loaded; even index is *not* guaranteed.

What I want to know is why Modifications is not being picked up properly and editing Subs.php to just bluntly state the title without i18n support is not solving the problem but sweeping it under the carpet.

Sir Osis of Liver

But he's not getting it any way he does it.  Concept works like any other theme and loads button labels from index.english.php.  Something else is causing the problem.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Semetery

It is now showing up but what's weird is that it has the proper actual link to my site in the menu even though I literally have 'mysiteurl.com' in the code..... it's like it's reading from an older version of the file when I had tried it previously?

I've cleared the cache numerous times and don't understand it. I added another button 'test' and it won't show up at all.

Arantor

An old version you say?

That does sound like caching, perhaps Zend OpCache or perhaps APC but the new upload should invalidate the existing cache.

Semetery

I'm just assuming since nowhere in my code is the proper url for that button. You can hover it and it shows 'midnightspookhouse.com' while in the code it has 'mysiteurl.com'. I just deleted my htaccess file to get rid of the Simple .htaccess Cache Mod but it didn't seem to change anything. I also wiped cache after deleting it.

I also went ahead and completely turned off caching on the forum for the time being.

Sir Osis of Liver

Here's your Subs.php.  What a mess. :P  Should work now.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

The 'Gallery' button is commented out, and there's a second 'Site' button below it that has the correct url.  Didn't change those.  You split some brackets where you shouldn't have, and buggered up the menu. 
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Here, I cleaned that up.  You should see two 'Site' buttons.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Semetery

That works a charm! Thank you so much, you've both been super helpful!

EDIT: Nevermind, you already told me where I went wrong. :)

Sir Osis of Liver

The main problem was you inserted the new buttons between the two closing brackets of the 'Forum' button instead of after, so everything between the brackets was lost.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Semetery

That makes sense, I basically fudged the entire thing by that error then. I also learned how to remove the 'Help' button now that I'm understanding the menu better and where to go to look into it.

Again, thanks so much for the help. I really appreciate it!

Advertisement: