Tags:
create new tag
view all tags

SID-01726: Navigation Bar, Change Active Topic to Active Web

Status: Unanswered Unanswered TWiki version: 5.1.3 Perl version:
Category: CategoryAddOns Server OS: Redhat linux Last update: 10 years ago

The Plugins.NavBarAddOn add on is not configured for cross-web navigation, ie, it only checks the topic name for displaying the active tab. I currently have a navigation bar embedded into my skin which has links to every webs home page (WebHome). I would like to have the active web highlighted within this bar and not the active topic. Whenever I go to a home page of any web, every single tab shows as active(because they all link to WebHome). I have spotted the existing line(s) within the Plugins.NavBarAddOn topic that controls this( so I believe) :


<script type="text/javascript">
 $(document).ready(function () {
  $("#navBar_%id%").children( 'ul' ).children( 'li' ).each( function( index ) {
    var topic = $(this).find('a').attr('href').replace( /.*\//, '' );
    if( %IF{ "defined 'active'" then="topic=='%active%' || " }% topic=='%BASETOPIC%' ) {
      var activeStyle = "background-color: #ffffff; border-color: #dddddf;";
%IF{ "defined 'NAVBARADDON_TAB_ACTIVE_STYLE'" then="    activeStyle=activeStyle+'%NAVBARADDON_TAB_ACTIVE_STYLE%;'" else="<nop>" }%
%IF{ "defined 'tab_active_style'" then="    activeStyle=activeStyle+';%tab_active_style%'" else="<nop>" }%
      var styleArr = activeStyle.split( / *; */ );
      for( i = 0; i < styleArr.length; i++) {
        var keyVal = styleArr[i].split( / *: */ );
        if( keyVal[0].length>0) {
          $(this).css( keyVal[0], keyVal[1] );
        }
      }
    }
  });
 });
</script>

I would like to extend this functionality to highlight the active web, and not the topic. To do this, I tried to extract a web variable by using the following regex ( grabs the first word with an upper case letter from the URL):

var web = window.location.pathname.match(/\/([A-Z][^\/]+)/); (Credits to TerjeAndersen for the line).

Then, I changed the next line to:

 if( %IF{ "defined 'active'" then="topic=='%active%' || " }% web =='%BASEWEB%' ) { 
, to check if the web is matched with the current baseweb ( which is what I want), but the active webs are not becoming active in the navigation bar.

The navigation bar is included within the TopMenuSkinTopBar topic via the following line:

 %INCLUDE{"SiteNavBar" }%
where SiteNavBar is the Navigation bar topic in the same web as TopMenuSkinTopBar

What is my error in doing this. If you could provide any insight, it would be much appreciated.

-- James DiDonato - 2013-06-10

Discussion and Answer

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the TWiki consultants if you need timely help. We invite you to get involved with the community, it is more likely you get community support if you support the open source project!

-- Peter Thoeny - 2015-12-03

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Unanswered
Title Navigation Bar, Change Active Topic to Active Web
SupportCategory CategoryAddOns
TWiki version 5.1.3
Server OS Redhat linux
Web server

Perl version

Browser & version

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2015-12-03 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.