Hi,
It's me again...
I wanted to add a button to the menu for Downloads but when I followed the instructions in the FAQ here I get no button at all.
Here's my code:
// Show the [download] button.
echo ($current_action == 'download' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'download' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=tpmod;dl">' , $txt['download'] , '</a>
</td>' , $current_action == 'download' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
I've added download to the other line mentioned in the FAQ too:
if (in_array($context['current_action'], array('gallery','search', 'admin', 'calendar', 'profile', 'mlist', 'download', 'register', 'login', 'help', 'pm', 'forum', 'tpadmin')))
$current_action = $context['current_action'];
If I switch the $txt['download'] back to $txt[119] (I copied the code for the Help button) I get a button called Help that goes to Downloads.
I take it the 119 is referencing something somewhere, is there another file I can update and use the number reference or is there something simple I'm missing?
The $txt values get loaded in the language files (in the 'languages' folder under default and modified/enhanced with those under specific theme).
try putting 'Downloads' (including the single quotes) where you have $txt['download'] or $txt[119] (or whatever is there at the moment.
I've changed these in a couple places but dont remember exactly where.
Look for files in your template theme that have the word english in the file name, like:
modifications.english.php
Something like that, in a couple of those files you'll find line after line of variables like that and you can add your own or change the ones that are there.
Thanks guys.
Okay, pasting in the 'Downloads' (or anything else for that matter) doesn't work.
Adding an entry in index.english.php and assigning a number to it does when I also update index.template.php with the same number. At least now there is a Downloads button.
Only problem now is the Downloads button doesn't get that surround graphic (the one that shows you which button your are currently on) in the menu when it's clicked.
Something else needs to be changed for that?
In the array line, you have to add downloads Not just 'download', your missing the s
Excuse me, but if you replaced:
<a href="', $scripturl, '?action=tpmod;dl">' , $txt['download'] , '</a>
With:
<a href="', $scripturl, '?action=tpmod;dl">' , 'Downloads' , '</a>
It definitely would have worked, as I use this construct.
Of course, this would, too:
<a href="', $scripturl, '?action=tpmod;dl">Downloads</a>
Quote from: G6 on October 04, 2007, 09:11:01 PM
In the array line, you have to add downloads Not just 'download', your missing the s
I'm not that familiar with this section of code, but is that true?
The 'action' being done isn't 'download' OR 'downloads'. As far as I can see, the 'action' being done is 'tpmod' (with a 'dl' parameter added for the type of module).
Hm, you might be correct again, i looked at one theme (the only theme i have the download button in the header) and in the array it say "downloads" but i dont know where the highligt for the actuall button is called from. if i remove the S from it, the button show the home tab as active when in the downloadsection
In the web2 theme it's made like this
$context['menubox'][]=array(
'title' => $txt['mydownload'],
'link' => $scripturl.'?action=tpmod;dl',
'chosen' => 'tpmod;dl',
So the array should perhaps be 'tpmod;dl', instead ???
I assume that THAT particular theme does the highlight based on matching the URL line to the value in 'chosen'.
Now you're in theme territory and that's definitely outside my zone. ;)
This is the default theme I'm working with and at the start I had download in the array and replacing help in the button section I copied but there was no download or button at all on the menu.
I added Downloads (originally it was download but it could as easily have been anything else) to the $txt part mentioned above but it did nothing. Only after updating the index.english.php did it work.
I've tried updating the array so that is uses tpmod;dl but it makes no difference, the button still gets no highlight graphic when clicked.
My code is now:
if (in_array($context['current_action'], array('gallery','search', 'admin', 'calendar', 'profile', 'mlist', 'tpmod;dl', 'register', 'login', 'help', 'pm', 'forum', 'tpadmin')))
$current_action = $context['current_action'];
and
// Show the [download] button.
echo ($current_action == 'tpmod;dl' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'tpmod;dl' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=tpmod;dl">' , $txt[999] , '</a>
</td>' , $current_action == 'tpmod;dl' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
with the following in index.english.php:
$txt[999] = 'Downloads';
As noted, you weren't supposed to add the 'Downloads' to anything, that was to replace what was in part of the code line as shown in the code lines provided. But using a language string is fine, too.
As also noted in above posts, the 'action taken is 'tpmod'. Appending the ';dl' simply gives an unnamed parameter to the URL 'command' line which can be used by the script to discern WHICH TP Module is to be run. But the action is NOT 'tpmod;dl'.
Try this:
if (in_array($context['current_action'], array('gallery','search', 'admin', 'calendar', 'profile', 'mlist', 'tpmod', 'register', 'login', 'help', 'pm', 'forum', 'tpadmin')))
$current_action = $context['current_action'];
And:
// Show the [download] button.
echo ((($current_action == 'tpmod') && isset($_GET['dl']) || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , (($current_action == 'tpmod') && isset($_GET['dl'])) ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=tpmod;dl">' , $txt[999] , '</a>
</td>' , (($current_action == 'tpmod') && isset($_GET['dl'])) ? '<td class="maintab_active_' . $last . '"> </td>' : '';
Haven't tested it, though.
No joy, unfortunately. Error screen attached.
Downloads was just a later addition. As mentioned all I originally did was copy the Help button code and follow the instructions as outlined in the Docs here which state to just replace help with download (or whatever) in the array and button info section.
I think i gave you one too many parentheses in that line. Try:
echo (($current_action == 'tpmod') && isset($_GET['dl']) || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
Same kind of error..just on line 686 now!
Line 686 is in the next section. Plase tost that download section as it is now and the next 6-12 lines.
Here's that whole section:
// 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('gallery','search', 'admin', 'calendar', 'profile', 'mlist', 'tpmod', 'register', 'login', 'help', 'pm', 'forum', 'tpadmin')))
$current_action = $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action = 'search';
if (isset($_GET['dl']))
$current_action = 'dlmanager';
if (isset($_GET['board']) || isset($_GET['topic']))
$current_action = 'forum';
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 , '"> </td>';
// Show the [home] button.
echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </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 . '"> </td>' : '';
if($settings['TPortal_front_type']!='boardindex')
// Show the [forum] button.
echo ($current_action=='forum' || $context['browser']['is_ie4']) ? '<td class="maintab_active_first"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action=='forum' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=forum">'.$txt['tp-forum'].'</a>
</td>' , $current_action=='forum' ? '<td class="maintab_active_last"> </td>' : '';
// Show the [help] button.
// echo ($current_action == 'help' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </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 . '"> </td>' : '';
// How about the [search] button?
// if ($context['allow_search'])
// echo ($current_action == 'search' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
// <td valign="top" class="maintab_' , $current_action == 'search' ? 'active_back' : 'back' , '">
// <a href="', $scripturl, '?action=search">' , $txt[182] , '</a>
// </td>' , $current_action == 'search' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin'])
echo ($current_action == 'admin' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'admin' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=admin">' , $txt[2] , '</a>
</td>' , $current_action == 'admin' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// Edit Profile... [profile]
if ($context['allow_edit_profile'])
echo ($current_action == 'profile' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'profile' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=profile">' , $txt[79] , '</a>
</td>' , $current_action == 'profile' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>
</td>' , $current_action == 'pm' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// The [calendar]!
if ($context['allow_calendar'])
echo ($current_action == 'calendar' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'calendar' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=calendar">' , $txt['calendar24'] , '</a>
</td>' , $current_action == 'calendar' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// the [member] list button
if ($context['allow_memberlist'])
echo ($current_action == 'mlist' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'mlist' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=mlist">' , $txt[331] , '</a>
</td>' , $current_action == 'mlist' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// the [SMF Gallery] button
if ($context['allow_smfgallery_view'])
echo ($current_action == 'gallery' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'gallery' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=gallery">' , $txt['smfgallery_menu'] , '</a>
</td>' , $current_action == 'gallery' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// Show the [download] button.
echo (($current_action == 'tpmod') && isset($_GET['dl']) || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , (($current_action == 'tpmod') && isset($_GET['dl'])) ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=tpmod;dl">' , $txt[999] , '</a>
</td>' , (($current_action == 'tpmod') && isset($_GET['dl'])) ? '<td
// If the user is a guest, show [login] button.
if ($context['user']['is_guest'])
echo ($current_action == 'login' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'login' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=login">' , $txt[34] , '</a>
</td>' , $current_action == 'login' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=register">' , $txt[97] , '</a>
</td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
</td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
// The end of tab section.
echo '
I can see right now that you missed the last part of the last line of the code.
Your download button section ends "? '<td"
Here is the section with fixed parantheses.
// Show the [download] button.
echo ((($current_action == 'tpmod') && isset($_GET['dl'])) || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , (($current_action == 'tpmod') && isset($_GET['dl'])) ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=tpmod;dl">' , $txt[999] , '</a>
</td>' , (($current_action == 'tpmod') && isset($_GET['dl'])) ? '<td class="maintab_active_' . $last . '"> </td>' : '';
Hello crew,
I belive that
if (isset($_GET['dl']))
$current_action = 'dlmanager';
is the cause here...commenting it out resolved the tab issue (after using lst post/code from Cortina on td fix) but I am not sure about the action "action=dlmanager;dl" ...where is this called out?
Thanks!
Its not action=dlmanager its action=tpmod;dl
I think this is a leftover from the default template but I didn't know where it is used...this has to be commented out in order to use Cortina's advice...according to my test, I am just not sure what consequences it has.
Quote from: J.A.Cortina on October 04, 2007, 10:34:46 PM
....
As also noted in above posts, the 'action taken is 'tpmod'. Appending the ';dl' simply gives an unnamed parameter to the URL 'command' line which can be used by the script to discern WHICH TP Module is to be run. But the action is NOT 'tpmod;dl'.
QuoteIts not action=dlmanager its action=tpmod;dl
So which one is it? Sorry to nag just want to make sure I don't push outbad template ???
I have got it working with:
if (isset($_GET['dl']))
$current_action = 'tpmod';//action=tpmod mod =dl
// Show the [download] button.
echo ((($current_action == 'tpmod') && isset($_GET['dl'])) || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , (($current_action == 'tpmod') && isset($_GET['dl'])) ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=tpmod;dl">' , $txt[MN_Downloads] , '</a>
</td>' , (($current_action == 'tpmod') && isset($_GET['dl'])) ? '<td class="maintab_active_' . $last . '"> </td>' : '';Thanks so much!!!