TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 468
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 119
  • Total: 119

A new button with highlighting in the Navbar on the top

Started by AgO, May 03, 2008, 07:09:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AgO

Hi,

in index.template.php some code determines on wich page a user is.
The highlighting of a button in the navbar depends on a variable-value.

// 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('teams', 'search', 'admin', 'calendar', 'profile', 'mlist', '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';
... and so on ...


How can I query (with IF) whether my new page was clicked?

The page hat this ending:

index.php?page=teams

My problem is, that my side has not the ending with "action" e.g.  ?action=teams.

The creation-code for the button is as follows:

// Show the [Squads & Wars] button.
                              echo '<li><a' , $current_action=='teams' ? ' class="current"' : '' , ' href="', $scripturl, '?page=teams"><span>' , "Squads & Wars" , '</span></a></li>';



I have to set the value of the variable $current_action to "teams", so that the css-class "current" is used on the right place.

So,
how i can give the right value to $current_action IF my new page was klicked?

Thanks a lot!


p.s.

If i try this code:

if (isset($_GET['page']))
$current_action = 'teams';


the highlighting works fine. But then there is a limit of 1 page to build-in ('page=teams' does not work).

IchBin

If you're page is truly set by action=teams, then add your teams word after tpadmin in the array. That is all you need to do.

AgO

No, the link of my new page is .../index.php?page=teams

Just add the string 'teams' to the array doesnt work.
All of the pages who are are linked in the top navbar have a link with .../index.php?action=whatever , EXEPT my new page.

I have to put some code that gives me a true if my new site (index.php?page=teams) was clicked. this code i will put into a IF Block so that i can give the value "teams" to the variable $current_action


If [my new page is the current one (index.php?page=teams)]     //this code snipped i need..
$current_action = 'teams';


then css should be assigned correctly

// Show the [Squads & Wars] button.
                              echo '<li><a' , $current_action=='teams' ? ' class="current"' : '' , ' href="', $scripturl, '?page=teams"><span>' , "Squads & Wars" , '</span></a></li>';

IchBin

if (isset($_GET['page']) && $_GET['page'] == 'teams')
    $current_action='teams';

AgO

YES, works like a charm!

exactly what i was looking for...

Thank you very much IchBin!


This website is proudly hosted on Crocweb Cloud Website Hosting.