Jump to content

Navigation help


SiNNuT
 Share

Recommended Posts

Because of my limited PHP skills i'm struggling a bit to generate a simple main navigation.

The tree is like this:

Home
-Menu
-Over
-Route
-Nieuws

But the navigation needs to have the homepage in the middle. The markup is like this:

<ul class="grid">
  <li class='grid-item one_fifth'><a href='/menu/'>Menu</a></li>
  <li class='grid-item one_fifth'><a href='/over/'>Over</a></li>
  <li class='grid-item one_fifth'><a class='logo' href='/'><img src='/site/templates/wbg/css/img/logo.png'></a></li>
  <li class='grid-item one_fifth'><a href='/route/'>Route</a></li>
  <li class='grid-item one_fifth'><a href='/nieuws/'>Nieuws</a></li>
</ul>

On the screen:

navi.png

It will probably always be logo center and two navigation items on each side but i would like to get a 'active' class on the a elements.

I wouldn't even mind hard coding some stuff but ideally the menu would dynamically reflect the page tree order for the four children, while still keeping the home link centered.

I've been trying to do some modifications on the default menu in head.inc but so far no luck.

Any help appreciated.

Link to comment
Share on other sites

Didn't test this one:

hope it works.

$home = $pages->get("/");
// all menu item exept home
$page_array = $home->children();

// count all items in $p_array
$count = count($page_array);
// all items divided by 2 + rounding down to integer
$position = floor($count/2);

$insert_after_page = $page_array->eq($position);
$page_array->insertAfter($home, $insert_after_page);

then: 

foreach($page_array as $p) {
    do your funky stuff
}
  • Like 2
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...