Website Button

Started by jake1981, May 19, 2007, 04:03:26 PM

Previous topic - Next topic

Jade Elizabeth

use one of the below

http://www.smfhacks.com/packageparser/package.php
http://sleepycode.com/PackageParser/index.php

select the mod from your computer, and then look for whats needed in the display and board templates and make sure its there :D
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

rehan

thX...
It was asking to edit few files which dont exist in my theme folder of city scape..
so i edited my theme file manually and was able to add the new button.. I added 2 buttons doing this.. one for my gallery and other for arcade section...

romuba

That is very good, which file and what did you edit?
Ross Bartholomew
email: [email protected]
www.bartwebsites.com

rehan

i edited index.template.php file inside my theme folder..

it wasn't hard to understand the button's code...


/ Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

// add buttons here
$context['menubox'] = array();

/*
'title' - the string the link will have
'link' - the actual link
'chosen' - which "current_action" this button belongs to.
'memberonly' - show it JUST for members
'guestonly' - show it JUST for guests
'permission' - any permission you want to check before displaying the button

*/

// home button
$context['menubox'][]=array(
'title' => $txt[103],
'link' => $scripturl,
'chosen' => '',
'memberonly' => false,
'guestonly' => false,
'permission' => '',
);

// Arcade button
$context['menubox'][]=array(
'title' => 'Arcade',
'link' => $scripturl.'?action=arcade',
'chosen' => 'Arcade',
'memberonly' => false,
'guestonly' => false,
'permission' => '',
);

// Gallery button
$context['menubox'][]=array(
'title' => 'Gallery',
'link' => 'http://www.circlebakote.com/gallery/index.php',
'chosen' => 'Arcade',
'memberonly' => false,
'guestonly' => false,
'permission' => '',
);



I just copy pasted the home button code for arcade and gallery..

romuba

Thanks a stack, I will give it a go.
Ross Bartholomew
email: [email protected]
www.bartwebsites.com

chrishicks

#65
anyone care to give me a tip on how to move the location of the button? its located all the way to the left but I'd like it at the right. dp I just take this code and place it after the code for the button I want it next to?

// Show the [website] button.

   show_websiteButton();
   
   


or is there something else I need to do as well?

Jade Elizabeth

Yeah, thats how you do it :D
If it fails, try again untill you get it right :D
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

djfermin

#67
spanish gif ....

christinedlrp

I'm having trouble adding the website button code to the Exodus theme.  Can someone please add it for me?  :D

58tbird

#69
Quote from: chrishicks on February 11, 2008, 10:41:36 AM
anyone care to give me a tip on how to move the location of the button? its located all the way to the left but I'd like it at the right. dp I just take this code and place it after the code for the button I want it next to?

// Show the [website] button.

   show_websiteButton();
   
or is there something else I need to do as well?

I have the same question - but I don't know what file to make these changes to.  I would like to move it just to the right of the Home tab. Nevermind - I found it in the index.template.php

However, I would like some help on this: when I click the Website tab, it works just fine, but the Home tab remains highlighted.  This give the impression one is still on the Home page.  Any way to make the Home tab return to normal size and dark blue, and make the Website tab enlarge and turn light blue after it's selected?

I noticed that the code for the other tabs (aside from the actual names of the tabs) appear this way:
// Show the [home] button.
echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'home' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '">' , $txt[103] , '</a>
</td>' , $current_action == 'home' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

...versus the code I quoted from chrischicks above for the Website Button.  I thought maybe I could simply copy this and change the names to match my new Website tab, but I noticed all the standard tabs contain their own unique number.  In the example shown here for the Home tab, it references "$txt[103]";  Help is "$txt[119]"; Search in "$txt[182]", etc.  Otherwise, they are all the same. 

Does anyone know how to make the new Website tab behave the same way all the other tabs do?

perplexed

#70
$txt['websiteButton_title']   - have you tried adding this in place of the $txt[103]etc?  I haven't tried it myself as I don't have this mod, but in lieu of a better reply...  I would say you need all of what is quoted in your post for the tabs to behave correctly as they have the maintab_active, active_back image references in them

58tbird

#71
Thank you my friend!

I hadn't thought of that - I don't really understand code much at all.  I tried your suggestion by replacing:
// Show the [website] button.

   show_websiteButton();


with:
// Show the [website] button.
echo ($current_action=='News%20Alerts' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'News%20Alerts' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '">' , $txt['websitebutton_News Alerts'] , '</a>
</td>' , $current_action == 'News%20Alerts' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


Then when I clicked on my News Alert tab I got the attached error.

The url for the custom action page I created is: http://mywebsite.com/index.php?action=News%20Alerts
So I figured I should put "News%20Alerts" after "action=" to match the other buttons (except Home, which has a different url).  I'm not sure at all if I should put "$txt['websitebutton_News Alerts']" or "$txt['websitebutton_News%20Alerts']" or some other variation.

Also, I don't know if I should replace this
// Show the [website] button.

   show_websiteButton();
or add the new code before/after it.

I see what the error highlights, but does that mean that's the only problem?


58tbird

#73
Thank you for the suggestion to use the Add a Tab Mod.  I already tried that, however, but I couldn't figure out a way to make the new tab open the News Alerts page (created using the Custom Action Mod).  I agree, however, that seems like the more logical approach to this dilemma, and I would prefer to use that solution in case I need to do something this again in the future.

perplexed

@ 58tbird I used to do this for one of my sites and the tab opened the external site no probs.

I have installed the website button again and I have moved italong the tab bar, and tried linking it to various internal forum pages and it works ok.  If you are linking to something inside the forum though then the home tab will stay highlighted probably because you are still there.  I tried linking it to the profile page and that took you to profile and then highlighted the profile tab since that's where I now was.  I think it's working the way it should be.

What page did you want to link it to, something internal or external?  If it's a page within the forum then I think that tab will stay highlighted to indicate you are still on the forum.

58tbird

#75
Wow, perplexed, I hope you're not going to too much trouble here for me.  I appreciate all your help on this.

I believe you can view my page here.  It's internal to my forum.  I was hoping to have the tab indicate to members and guests that they are currently on the News Alerts page.  Instead, when they're on this page, it appears by the highlighted Home tab that they're on the Home page.

I'm wondering if $txt[103], etc. refers to a file somewhere that lists the various pages and assigns them a number.  If so, maybe I could assign a number to my News Alerts page so the code will call it just like all the others.  I guess not...according to  How do you add custom tabs   
Quote* $current_action=='home' - is what sets the tab for the current actions.  As you can see it is defined in 3 instances.  You will need to change it for all three of them.
    * ' , $txt[103] , ' - is the text string that prints Home on the Main menu.  As you see the variable is inside ' , , '.  The reason for this is because it's inside an echo.  If you are going to hard code the name in the menu you do not need to put ' , , ' around it.

I wonder what I need to do to hard code this, and if that's the solution I'm looking for.

58tbird

Well, I tried using $txt['websiteButtonAlt_txt'] in the code in place of ' , $txt[103] , ' but it seems the code is ignored and only the // Show the [website] button.

   show_websiteButton();
works.  I tried eliminating it but the result is that clicking on the News Alerts tab has no effect (stays on Home page).

I suspect it must have something to do with the preceding section of the code which seems to define the operation:
// Show WebsiteButton
function show_websiteButton()
{
global $context, $txt, $modSettings;

echo $context['browser']['is_ie4'] ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '', '
<td valign="top" class="maintab_back">
<a href="', isset($modSettings['websiteButton_url']) ? $modSettings['websiteButton_url'] : 'http://www.roadrunner.cx', '" alt="', isset($txt['websiteButtonAlt_txt']) ? $txt['websiteButtonAlt_txt'] : 'Website', '">',
isset($txt['websiteButton_txt']) ? $txt['websiteButton_txt'] : 'Website', '</a>
</td>';
}
// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

// Work out where we currently are.
$current_action = 'home';
if (in_array($context['current_action'], array('admin', 'ban', 'boardrecount', 'cleanperms', 'detailedversion', 'dumpdb', 'featuresettings', 'featuresettings2', 'findmember', 'maintain', 'manageattachments', 'manageboards', 'managecalendar', 'managesearch', 'membergroups', 'modlog', 'news', 'optimizetables', 'packageget', 'packages', 'permissions', 'pgdownload', 'postsettings', 'regcenter', 'repairboards', 'reports', 'serversettings', 'serversettings2', 'smileys', 'viewErrorLog', 'viewmembers')))
$current_action = 'admin';
if (in_array($context['current_action'], array('search', 'bookmarks', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm')))
$current_action = $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action = 'search';
if ($context['current_action'] == 'news')
$current_action = 'news';
if ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';

// Are we using right-to-left orientation?
if ($context['right_to_left'])
{
$first = 'last';
$last = 'first';
}
else
{
$first = 'first';
$last = 'last';
}

// Show the start of the tab section.
echo '
<table cellpadding="0" cellspacing="0" border="0" style="margin-left: 10px;">
<tr>
<td class="maintab_' , $first , '">&nbsp;</td>';


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

// Show the [website] button.

show_websiteButton();

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


I just don't know how to read this stuff. :(

ccbtimewiz

#77
Here, I've taken the liberty to make my own small modification in the code.

Uninstall the website button modification and place this instead. Please note I am in no way affiliated with the mod author of the Website Button modification and I don't intend to "rival" them. This is just a solution to solve your problem.

Replace the code you posted above with this:

Code (index.template.php) Select
// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

// Website Button modification.
// --- Main override of the modification. Use "Yes" to enable, use "No" to disable.
$enable_website_button = 'Yes';
// --- Replace this with your own link. Only works if "Yes" is put into the enable_website_button field.
$website_button_link = 'http://www.roadrunner.cx';
// --- The actual text of the button. Only works if "Yes" is put into the enable_website_button field.
$website_button_text = 'Road Runner';
//--------

// Work out where we currently are.
$current_action = 'home';
if (in_array($context['current_action'], array('admin', 'ban', 'boardrecount', 'cleanperms', 'detailedversion', 'dumpdb', 'featuresettings', 'featuresettings2', 'findmember', 'maintain', 'manageattachments', 'manageboards', 'managecalendar', 'managesearch', 'membergroups', 'modlog', 'news', 'optimizetables', 'packageget', 'packages', 'permissions', 'pgdownload', 'postsettings', 'regcenter', 'repairboards', 'reports', 'serversettings', 'serversettings2', 'smileys', 'viewErrorLog', 'viewmembers')))
$current_action = 'admin';
if (in_array($context['current_action'], array('search', 'bookmarks', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm')))
$current_action = $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action = 'search';
if ($context['current_action'] == 'news')
$current_action = 'news';
if ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';

// Are we using right-to-left orientation?
if ($context['right_to_left'])
{
$first = 'last';
$last = 'first';
}
else
{
$first = 'first';
$last = 'last';
}

// Show the start of the tab section.
echo '
<table cellpadding="0" cellspacing="0" border="0" style="margin-left: 10px;">
<tr>
<td class="maintab_' , $first , '">&nbsp;</td>';


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

// Your [website] button.
echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'home' ? 'active_back' : 'back' , '">
<a href="'.$website_button_link.'" target="_blank">'.$website_button_text.'</a>
</td>' , $current_action == 'home' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

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

58tbird

Thank you ccbtimewiz!  I'm eager to try your solution, however, I'm a little stuck.

I've been trying to uninstall the Website Button mod but two files fail the test.  After using the package parser and making several unsuccessful attempts to locate and correct the manual changes I may have made that are causing the test failure, I dug down through previous backups to my themes/default/index.template.php, and finally found one to revert back to that passes the test. 

But I also fail Themes/default/languages/index.english.php.  I don't remember altering this file manually at all, like I did the index.template.php.  Using the package parser, I see the only thing needed for uninstalling is to delete $helptxt['websiteButton_url'] = 'This is URL where you want your website button to point to, for example http://www.roadrunner.cx';however, I've searched that file and this line doesn't exist. 

Using the package parser, instructions to install show that code is to be added to the end of the file.  I tried adding it here:
$txt['websiteButton_txt'] = 'News Alerts';
$txt['websiteButtonAlt_txt'] = 'News Alerts'
;
?>

to look like this:
$txt['websiteButton_txt'] = 'News Alerts';
$txt['websiteButtonAlt_txt'] = 'News Alerts'
;
$helptxt['websiteButton_url'] = 'This is URL where you want your website button to point to, for example http://www.roadrunner.cx';
?>
but it still fails the test.  Since I'm new, I don't know if it's safe to go ahead with the uninstall or not.  Can you advise me how I should proceed?

ccbtimewiz

Proceed with uninstalling.

Advertisement: