SiNNuT Posted October 7, 2013 Share Posted October 7, 2013 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: 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 More sharing options...
totoff Posted October 7, 2013 Share Posted October 7, 2013 very limited in time my first idea for this kind of "dom manipulation" would be jquery rather than php. maybe this helps: http://tinysort.sjeiti.com/ Link to comment Share on other sites More sharing options...
Martijn Geerts Posted October 7, 2013 Share Posted October 7, 2013 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 } 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now