News:

Wondering if this will always be free?  See why free is better.

Main Menu

Adding Navigation Buttons

Started by bburg5, February 17, 2009, 04:18:06 PM

Previous topic - Next topic

bburg5

#20
Quote from: johnswhite on March 06, 2009, 07:48:59 PM
Could someone tell me what is wrong with the following code to add a button called bay2bay which will link to the main website's home page.

// Show the [{bay2bay}] button.
    echo ($current_action == 'bay2bay}' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
                <td valign="top" class="maintab_' , $current_action == 'bay2bay' ? 'active_back' : 'back' , '">
                    <a href="',$scripturl, '?action=bay2bay">' , $txt['bay2bay'] , '[/url]
                </td>' , $current_action == 'bay2bay' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

I've added this to ...\default\index.template.php

Many thanks
John

I am very new to this, but after many-many trials I was able to get it to work. It is definitely not pretty coding, but you may want to try copying an existing button on your forum, keeping the existing $current_action of the button, changing the "',$scripturl, '?action=bay2bay" to "http://website URL" and adding the text needed for "$txt['bay2bay']" to your default language index.english.php file. Make sure you add the correct number from language file to the $txt[##] in the code.

May sound confusing, but it worked for me. Probably not the correct way, but it worked. ;)




tyty1234

did you make sure you defined $context['current_action'] = 'bay2bay'?
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

bburg5

Quote from: tyty1234 on March 06, 2009, 11:05:29 PM
did you make sure you defined $context['current_action'] = 'bay2bay'?

Just so I can clean up my code later----

How would you define the "$context['current_action']"  ? I have the buttons working, but still have their original "$context['current_action']" listed. Just changed the "$txt" and "a href"

Thanks

tyty1234

Look for something like this:


if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm')))


And at the end of this array, add 'bay2bay'.
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

johnswhite

Thank you for the replies. I did have $context['current_action'] = 'bay2bay'? but with the rest of the code written, when I uploaded, it would not work and I got a syntax error, so I had to delete it all.
Can anyone see any obvious problem with the code I had.
With regard to the
"',$scripturl, '?action=bay2bay" to "http://website URL"
is that how it should appear or do I change the word 'website' to 'bay2bay.co.uk' or leave off the .co.uk?
Many thanks
John

tyty1234


<a href="',$scripturl, '?action=bay2bay">' , $txt['bay2bay'] , '[/url]


should be


<a href="',$scripturl, '?action=bay2bay">' , $txt['bay2bay'] , '</a>


You should not use bbcode in html.
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

johnswhite

Thank you for that, I have now got a button with B2B Home written in it. The problem remains to make it go somewhere when clicked? Can you help with that?
Regards
John

tyty1234

My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

johnswhite

               
<a href="', $scripturl, 'action=http://www.bay2bay.co.uk/index.html [nofollow]">' , $txt[120] , '</a>

I am sure it is something to do with this line....
Please don't laugh
Regards
John

tyty1234

well, if you want just http://www.bay2bay.co.uk/index.html, then you would have to remove the scripturl, and the action as you are linking it off your site.


<a href="http://www.bay2bay.co.uk/index.html">' , $txt[120] , '</a>
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

Advertisement: