#1 April 25, 2016 9:18am

userbot
Member
Registered: April 22, 2016
Posts: 31

How to add a "active» css, in navigation menu?

FluxBB bbcode test

HELP ME

Offline

#2 April 25, 2016 9:57am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 978

Re: How to add a "active» css, in navigation menu?

You can see an example of how to check for the active status of navigation in the example site's footer beginning at line 17:

https://github.com/bigtreecms/BigTree-C … footer.php

Offline

#3 April 25, 2016 10:00am

userbot
Member
Registered: April 22, 2016
Posts: 31

Re: How to add a "active» css, in navigation menu?

timbuckingham wrote:

You can see an example of how to check for the active status of navigation in the example site's footer beginning at line 17:

https://github.com/bigtreecms/BigTree-C … footer.php

No works in footer  and header

<? $main_nav = $cms->getNavByParent(0,2); ?>
    <? foreach ($main_nav as $navItem) { $active = (strpos($current_url,$navItem["link"]) !== false); ?>
         <a class="tf-menu <? if ($active) { ?>tf-active<? } ?>" href="<?=$navItem["link"]?>" <?=targetBlank($navItem["link"])?>> <?=$navItem["title"]?></a>
    <? } ?>

Offline

#4 April 25, 2016 10:02am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 978

Re: How to add a "active» css, in navigation menu?

Did you set $current_url to be the current URL in your template? If not, it will be an empty string and strpos will always return true.

$current_url = BigTree::currentURL();

Offline

#5 April 25, 2016 10:05am

userbot
Member
Registered: April 22, 2016
Posts: 31

Re: How to add a "active» css, in navigation menu?

timbuckingham wrote:

Did you set $current_url to be the current URL in your template? If not, it will be an empty string and strpos will always return true.

$current_url = BigTree::currentURL();

my tempalte

<?
    $current_url = BigTree::currentURL();
    $home_page = $cms->getPage(0);
   
    if ($bigtree["page"]["id"]) {
        $bigtree["page"]["title"] .= "&nbsp;&middot;&nbsp;".$home_page["nav_title"];
    }
?><!DOCTYPE html>

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.