News:

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

Main Menu

2 Home Buttons

Started by S.T.A.R.S, July 07, 2011, 07:07:48 PM

Previous topic - Next topic

S.T.A.R.S

Is there any possibility of two home buttons. Maybe one of "Website" and one of "Home or Forum"?

Thanks
Currently Developing a Gaming Site and Forum. Providing forums for all gamers around the world to socialise and dicuss with others. We support all genres of games!

Currently underdevelopment!

Need any Website Based help? PM me on Facebook

PM Me for Details, in need of sensible reliable moderators.

DxXCory

You can do that (the easy way) by installing the 6 Custom Tabs mod. You can find it by going to the mod site. :D

Sir Osis of Liver


It's a simple edit in /Sources/Subs.php.  Find the button array, copy the code to add a button, substitute your url and title.

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

                                     - R. Waters

hcfwesker

I was also wondering this, but how would you substitue a hard link, where it usually says href=> scriptural?   in subs.php

mashby

So this would be the forum URL:
'href' => $scripturl,
I think you can hardcode your site URL something like this:
'href' => 'http://www.yoursite.com/',I think that will work out assuming you change the actual destination.
Always be a little kinder than necessary.
- James M. Barrie

Sir Osis of Liver


Ok, in /Sources/Subs.php, you find this:



// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
if (($menu_buttons = cache_get_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'])
{
$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
'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(
),
),




Copy this where you want the new button:



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




...and change it to this:



'google' => array(
'title' => 'Google',
'href' => 'http://www.google.com' . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),



If you don't see the new button, comment out this line until you're done:



// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
// if (($menu_buttons = cache_get_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'])


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

                                     - R. Waters

hcfwesker

Quote from: mashby on July 08, 2011, 12:02:06 AM
So this would be the forum URL:
'href' => $scripturl,
I think you can hardcode your site URL something like this:
'href' => 'http://www.yoursite.com/',I think that will work out assuming you change the actual destination.

I tried that before, but I forgot the comma on the end.  I suck lol

thanx for your help, bud.

Matthew K.

I wrote a mod for this? Customizable Home Button. Exactly what you guys are looking for, with no edits necessary.

S.T.A.R.S

Mods do not work on my SMF, never have, never will.

Also, i edited the Subs.php but i get given an error within this code after inserting  a new link, but i cant seem to find the errors, anyone help?

// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
if (($menu_buttons = cache_get_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'])
{
$buttons = array(
'website' => array(
'title' => $txt['Website'],
'href' => http://www.mmogamer.co.uk . '?action=help',
'show' => true,
'sub_buttons' => array(
),
'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
'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(
),
),
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => $context['allow_admin'],
'sub_buttons' => array(
'featuresettings' => array(
'title' => $txt['modSettings_title'],
'href' => $scripturl . '?action=admin;area=featuresettings',
'show' => allowedTo('admin_forum'),
Currently Developing a Gaming Site and Forum. Providing forums for all gamers around the world to socialise and dicuss with others. We support all genres of games!

Currently underdevelopment!

Need any Website Based help? PM me on Facebook

PM Me for Details, in need of sensible reliable moderators.

Illori

'href' => http://www.mmogamer.co.uk . '?action=help',

should be
'href' => $scripturl . '?action=help',

or i think

'href' =>http://www.mmogamer.co.uk, might work although i did not test that one.

S.T.A.R.S

Currently Developing a Gaming Site and Forum. Providing forums for all gamers around the world to socialise and dicuss with others. We support all genres of games!

Currently underdevelopment!

Need any Website Based help? PM me on Facebook

PM Me for Details, in need of sensible reliable moderators.

Matthew K.

The href for your website button needs to be in single quotes.

S.T.A.R.S

Sorry, what do you mean?

thanks
Currently Developing a Gaming Site and Forum. Providing forums for all gamers around the world to socialise and dicuss with others. We support all genres of games!

Currently underdevelopment!

Need any Website Based help? PM me on Facebook

PM Me for Details, in need of sensible reliable moderators.

Matthew K.

Code (Find) Select
'website' => array(
'title' => $txt['Website'],
'href' => http://www.mmogamer.co.uk, . '?action=help',
'show' => true,
'sub_buttons' => array(
),

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

S.T.A.R.S

Ok thanks.

I've added it to my code. Overall it is :

// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
if (($menu_buttons = cache_get_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'])
{
$buttons = array(
'website' => array(
'title' => $txt['Website'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),
'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),


When i visit my site of www.mmogamer.co.uk/forum . No "website" button is on the navigation bar :(

thanks for ur help
Currently Developing a Gaming Site and Forum. Providing forums for all gamers around the world to socialise and dicuss with others. We support all genres of games!

Currently underdevelopment!

Need any Website Based help? PM me on Facebook

PM Me for Details, in need of sensible reliable moderators.

Matthew K.

Did you add the text string $txt['Website'] to a language file? You can't just expect text to show up if you don't define it...

S.T.A.R.S

Ah right  :P

First time using these language files, which one is it which i edit? What code do i insert?

Thanks for ur help i appreciate it :)
Currently Developing a Gaming Site and Forum. Providing forums for all gamers around the world to socialise and dicuss with others. We support all genres of games!

Currently underdevelopment!

Need any Website Based help? PM me on Facebook

PM Me for Details, in need of sensible reliable moderators.

Matthew K.

Well, it's probably best to put it in Modifications.english.php

Just add
$txt['Website'] = 'Website';

Sir Osis of Liver


Just copy the code for the Google button I posted above and change the name and url.  You can either use a variable without single quotes, or the actual url and name in quotes, but won't work if you mix them.

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

                                     - R. Waters

Matthew K.

Krash. - Addressing some flaws I see in your code...

First off, why in the world would you do this...
'href' => 'http://www.google.com' . '?action=help',
There is absolutely no need to have ' . '.

Furthermore, if they can't see the button, why comment out caching? That would also throw an error because you didn't comment out the closing if statement bracket, meaning there'll be a floating closing bracket that doesn't link to anything.

If they can't see the button? Use maintenance to clear the file cache, or just change the cache level to 1 or 2. As the menu is only cached on cache level 3.

Sir Osis of Liver


I left that in because it works that way, and minimizes the edit.  The more you change, the more likely it'll get buggered up.

I suggested commenting out the caching just while doing the edit, makes it easier to see the changes, and you're aleady editing that area.  Should have made it clear that the caching line should be restored when the edit is finished.

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

                                     - R. Waters

Matthew K.

' . ' is not necessary, if anything it makes it much more complicated than it really needs to be. Regarding commenting it out, as I said, it's not really necessary, especially since just commenting out that line will kill SMF, as I said because the closing bracket would be left.

S.T.A.R.S

Where is Modifications.english.php located?
Currently Developing a Gaming Site and Forum. Providing forums for all gamers around the world to socialise and dicuss with others. We support all genres of games!

Currently underdevelopment!

Need any Website Based help? PM me on Facebook

PM Me for Details, in need of sensible reliable moderators.

Nick Whetstone

Quote from: S.T.A.R.S on July 08, 2011, 03:16:34 PM
Where is Modifications.english.php located?
/Themes/default/languages/
The artist formerly known as (Ha)²

Former Support Specialist

Please do not solicit support via PM. Here's why!

Sir Osis of Liver

Quote from: Labradoodle-360 on July 08, 2011, 03:02:06 PM
' . ' is not necessary, if anything it makes it much more complicated than it really needs to be. Regarding commenting it out, as I said, it's not really necessary, especially since just commenting out that line will kill SMF, as I said because the closing bracket would be left.

Sorry, that was a post-and-run, and I didn't explain it well.  The point of the code I posted was to show that we are replacing a variable with a string, and that's the simplest and clearest way to do it, especially for a member who may be unfamiliar with SMF/php.  Agreed, the syntax is clunky, but it's correct, and will work properly. 

I commented out the caching code on my 2.0 install to facilitate viewing the edit, and it didn't cause any problems - would not have posted it if I hadn't tried it.  Certainly it should not be left that way, and I suppose I could have made that clearer.

My code may not be elegant, but it werks gud. 


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

                                     - R. Waters

S.T.A.R.S

Ok thankyou its working.

When i click on theb utton it displays this information:

QuoteWelcome to MMO Multi Gaming Resource, powered by Simple Machines® Forum (SMF) software!

SMF® is the elegant, effective, powerful and free forum software solution that this site is running. It allows users to communicate in discussion topics on a given subject in a clever and organized manner. Furthermore, it has a number of powerful features which end users can take advantage of. Help for many of SMF's features can be found by either clicking the question mark icon next to the relevant section or by selecting one of the links on this page. These links will take you to SMF's centrally-located documentation on the Simple Machines official site.

    Registering - Many forums require users to register to gain full access.
    Logging In - Once registered, users must login to access their account.
    Profile - Each member has their own personal profile.
    Search - Searching is an extremely helpful tool for finding information in posts and topics.
    Posting - The whole point of a forum, posting allows users to express themselves.
    Bulletin Board Code (BBC) - Posts can be spiced up with a little BBC.
    Personal Messages - Users can send personal messages to each other.
    Memberlist - The memberlist shows all the members of a forum.
    Calendar - Users can keep track of events, holidays, and birthdays with the calendar.
    Features - Here is a list of the most popular features in SMF.

For more information about how to use SMF, please see the Simple Machines Documentation Wiki and check out the credits to find out who has made SMF what it is today.

Is there anyway i can redirect the user to another webpage once he/she clicks on the "website" link?

thanks
Currently Developing a Gaming Site and Forum. Providing forums for all gamers around the world to socialise and dicuss with others. We support all genres of games!

Currently underdevelopment!

Need any Website Based help? PM me on Facebook

PM Me for Details, in need of sensible reliable moderators.

Sir Osis of Liver


Um....thought that was explained (several ways) at the top of this thread.  What are you missing?

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

                                     - R. Waters

Advertisement: