Jump to content

How to make parent link active


peterpp
 Share

Recommended Posts

Something like this:

$search_in_parents = $page->parents->get($current_menu_page);

if( !$search_in_parents->id ) echo "<li>…</li>"; // Not found
else echo "<li class='highlight'></li>"; // Found in Parents

If your childpages are only direct descendants you may use this to check for the one direct parent:

if( $page->parent == $current_menu_page ) echo "It's the first Parent!";
Link to comment
Share on other sites

Something like this:

$search_in_parents = $page->parents->get($current_menu_page);

if( !$search_in_parents->id ) echo "<li>…</li>"; // Not found
else echo "<li class='highlight'></li>"; // Found in Parents

If your childpages are only direct descendants you may use this to check for the one direct parent:

if( $page->parent == $current_menu_page ) echo "It's the first Parent!";

HI LostKobrakai,

  Thanx for your reply. I pasting my code.  I am using processwire with foundation zurb. So plz help me in modifying code.

<section class="top-bar-section">

<?php

                echo "<ul class='left'>";

                echo "<li class='has-dropdown'>";

                $p = $pages->get(1001);

                

                echo "<a href='$p->url'>$p->title</a>";

                echo "<ul class='dropdown'>";

                $p = $pages->get(1001)->children;

                foreach( $p as $k ){

                    

                    echo "<li><a href='$k->url'>$k->title</a></li>";                    

                }

                echo "</ul>";

                echo "</li>";

                echo "</ul>";

?>

</section>

Regards,

Pravin

Link to comment
Share on other sites


<ul class='left'>

<?php

$menu_page = $pages->get(1001);

if( $page->parent == $menu_page ) echo "<li class='highlight has-dropdown'>";

else echo "<li class='has-dropdown'>";

echo "<a href='$menu_page->url'>$menu_page->title</a>";

?>

<ul class='dropdown'>

<?php

foreach($menu_page->children as $child ){

echo "<li><a href='$child->url'>$child->title</a></li>";

}

?>

<ul>

</li>

</ul>

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...