Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: RL Joneson on April 05, 2008, 06:32:43 PM

Title: Adding Nav Buttions in 2.0
Post by: RL Joneson on April 05, 2008, 06:32:43 PM
How do you add buttons in 2.0? i see that the language code has changed. I want to simply add custom linked buttons to the nav bar. For instance, an "About" button would link to a custom url.
Title: Re: Adding Nav Buttions in 2.0
Post by: babjusi on April 05, 2008, 06:37:29 PM
Quote from: RL Joneson on April 05, 2008, 06:32:43 PM
How do you add buttons in 2.0? i see that the language code has changed. I want to simply add custom linked buttons to the nav bar. For instance, an "About" button would link to a custom url.

In the 2.0 that has been moved from the index.template.php file to the Subs.php in the /Sources/ directory so it can affect all templates.

Try to search for
Quote$buttons = array(
Title: Re: Adding Nav Buttions in 2.0
Post by: RL Joneson on April 05, 2008, 07:08:11 PM
Great! But how do i change the href to link to a url? I put this code in and it isn't working.


'home' => array(
'title' => $txt['home'],
'href' => http://rljoneson.com/faf/home/home.html,
'show' => true,
'sub_buttons' => array(
),
),
Title: Re: Adding Nav Buttions in 2.0
Post by: Oldiesmann on April 05, 2008, 07:29:11 PM
Make sure $txt['home'] is a real text string.
Title: Re: Adding Nav Buttions in 2.0
Post by: RL Joneson on April 05, 2008, 07:31:45 PM
It is right? I just wanted to change the link to where the current HOME button goes to.
Title: Re: Adding Nav Buttions in 2.0
Post by: RL Joneson on April 05, 2008, 07:53:30 PM
I mean that IS a REAL string right? it's out of the languages/englishindex. I just want it to link to the url instead of having it go to the forum home.
Title: Re: Adding Nav Buttions in 2.0
Post by: smack on April 05, 2008, 09:12:02 PM
I don't think you can change that, $scripturl because it is using the site url from setting i think, then half of your board links wont work.

I would love to add a button to my 2.0 site just to see how it works but I can't find a way to do it.   I guess i will just have to live with it.
Title: Re: Adding Nav Buttions in 2.0
Post by: Bulakbol on April 05, 2008, 10:20:35 PM
It might work if you sorround your home page with single quote.
'href' => 'http://rljoneson.com/faf/home/home.html',
Title: Re: Adding Nav Buttions in 2.0
Post by: smack on April 06, 2008, 07:13:55 AM
It works like a baby, thanks.

But I would still like to know how to add a button, I am trying to learn as much  as I can.  You just can't copy code like:


'home' => array(
'title' => $txt['home'],
'href' => 'http://www.yoururl.com',
'show' => true,
'sub_buttons' => array(
),
),


And expect a button to apear right? 
There are other places that need to be modified also, is there a place where I can go and learn those steps?
Title: Re: Adding Nav Buttions in 2.0
Post by: RL Joneson on April 06, 2008, 01:20:37 PM
I've added buttons to mine, but something weird is happening to my finished result. There is a colon ":" at the end of my button name. Here is the code i added to make the new buttons

{
$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => 'http://rljoneson.com/faf/home/home.html',
'show' => true,
'sub_buttons' => array(
),
),
'events' => array(
'title' => $txt['events'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
),
'jobs/resumes' => array(
'title' => $txt['jobs'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
),
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),
'search' => array(
'title' => $txt['search'],
'href' => $scripturl . '?action=search',
'show' => $context['allow_search'],
'sub_buttons' => array(
),


And here is where you can view it. rljoneson.com/faf_forum (http://rljoneson.com/faf_forum)

And here is my index.english code where i added the new labels

$txt['message_index'] = 'Message Index';
$txt['news'] = 'News';
$txt['home'] = 'Home';
$txt['events'] = 'Events';
$txt['jobs'] = 'Jobs/Resumes';


Does anyone know why my "Events"  button has the colon at the end "Events:" ??
Title: Re: Adding Nav Buttions in 2.0
Post by: RL Joneson on April 06, 2008, 01:24:29 PM
FYI the Jobs/Resume one turned out find. Just the Events has the issue. I can't figure this one out...
Title: Re: Adding Nav Buttions in 2.0
Post by: Bulakbol on April 06, 2008, 02:04:34 PM
I tried just the events and looks fine here with the default theme.
Title: Re: Adding Nav Buttions in 2.0
Post by: RL Joneson on April 06, 2008, 04:35:52 PM
I've tested it on all browsers. IE5 win, IE mac, Safari, Firefox.. and i see the ":" on my Events: button. Does anyone else see it?? i just want to get rid of it.

rljoneson.com/faf_forum (http://rljoneson.com/faf_forum)
Title: Re: Adding Nav Buttions in 2.0
Post by: Altair on April 06, 2008, 04:43:42 PM
Try adding an action to the events line. That MIGHT be what is causing it, but I am not to sure.
Title: Re: Adding Nav Buttions in 2.0
Post by: RL Joneson on April 06, 2008, 05:23:51 PM
Yes there's an ARRAY in the line right?
Title: Re: Adding Nav Buttions in 2.0
Post by: Nigel on April 06, 2008, 06:09:46 PM
Hi RL Joneson,

I've just searched 'index.english' and $txt['events'] has already been defined. Guess what it's defined as?

So it's probably best if you use another name – editing that entry might have strange consequences elsewhere.

BTW, have you read the note at the top of that file re clearing the cache? That one had me fooled for a while.

Nigel
Title: Re: Adding Nav Buttions in 2.0
Post by: Bulakbol on April 06, 2008, 10:37:32 PM
There's $txt['calendar4'] = 'Events:'; in the index.english.php. If you just copied it, there's colon at the end. Double check it.  :P
Title: Re: Adding Nav Buttions in 2.0
Post by: metallica48423 on April 06, 2008, 11:35:54 PM
I made a little thing on constructing your own links...

http://www.simplemachines.org/community/index.php?topic=229686.msg1476576#msg1476576

Title: Re: Adding Nav Buttions in 2.0
Post by: RL Joneson on April 07, 2008, 11:42:39 AM
Yes i just changed it in the lang script to say something other than 'events'. i called it 'eventnav'. case closed on this one, however it raises two more questions. will start new threads. thanks SMF team, you guys have the BEST community support out there!
Title: Re: Adding Nav Buttions in 2.0
Post by: Waxman on June 07, 2008, 02:34:15 AM
where can I find this index.english.php I wish my FTP had a search
man just as he posted I found one.

Title: Re: Adding Nav Buttions in 2.0
Post by: Waxman on June 07, 2008, 03:05:16 AM
Ok it didn't work
I suscsesfully xhanged the Home button to go to my home page but no new button appered when I tyed in (all in correct specing)
'forum' => array(
'title' => $txt['forum'],
'href' => '$scipturl',
'show' => true,
'sub_buttons' => array(
),
                        ),

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

after i changed my index.english.php to

$txt['message_index'] = 'Message Index';
$txt['news'] = 'News';
$txt['home'] = 'Home';
$txt['forum'] = 'forum';

what did I do wrong?
Title: Re: Adding Nav Buttions in 2.0
Post by: Waxman on June 07, 2008, 03:34:36 AM
I also tried changing the name in my index.english.php from

$txt['message_index'] = 'Message Index';
$txt['news'] = 'News';
$txt['home'] = 'Home';
$txt['forum'] = 'forum';

to
$txt['message_index'] = 'Message Index';
$txt['news'] = 'News';
$txt['home'] = 'Home';
$txt['pegasusreplicators_message_boaards'] = 'pegasusreplicators message boards';

and my forums still disappeared(restored backups so site is OK)
Title: Re: Adding Nav Buttions in 2.0
Post by: Nathaniel on June 07, 2008, 03:43:44 AM
Try clearing your file cache in the admin section -> 'Maintenance' menu -> 'Maintenance' tab -> 'Common Tasks' tab -> 'Empty the file cache.' link/option.

Theme/template files in SMF 2 including language files are all cached to save on time and space, because of this you have to wipe the cache before any changes will be loaded.
Title: Re: Adding Nav Buttions in 2.0
Post by: Waxman on June 07, 2008, 03:59:28 AM
site still does not show up
Title: Re: Adding Nav Buttions in 2.0
Post by: metallica48423 on June 07, 2008, 04:10:12 AM
/Themes/default/languages
Title: Re: Adding Nav Buttions in 2.0
Post by: Waxman on June 07, 2008, 04:19:03 AM
thank you I found it earlier but when i did as you suggested in your tut my board dissapered and I had to load backups, LHVWB said to clear my cache but the didn't help either

I am running the 2.0 beta 3.1 public
I really like this board and want to figure this out
Title: Re: Adding Nav Buttions in 2.0
Post by: Darkness_ on December 10, 2008, 06:54:46 PM
http://www.amenna.nl/forum2/index.php

between index and help there should be lounge
but there is a gap in it, if you searh a bit in the gap you could find it but. the text isn't showing up.....

subs.php
'Lounge' => array(
'title' => $txt['lounge300500'],
'href' => "http://www.amenna.nl/forum2/Lounge.php",
'show' => true,
'sub_buttons' => array(
),
),


index.dutch-utf8.php
$txt['lounge300500'] = 'Lounge';

but it doesn't show up :S
Title: Re: Adding Nav Buttions in 2.0
Post by: Darkness_ on December 10, 2008, 06:59:00 PM
^changed it the  $txt['lounge300500'] = 'Lounge';   in 'Lounge' then it shows up, but isn't it better when it has been added to the language files?