building a auto nav but only show children when you click on parent

Permalink
I have been looking through the forums but I cannot find a solution for building a auto-nav so that when you click on a parent item, it then shows the children. I do not want to display all children when the root nav items are selected. I have tried to use the CID of the parent item but that just shows children menu of that parent item. I want to show the all parent nav items but when I select a certain parent item, it shows the children of that parent item. I tried using this:


<?php
$nav = BlockType::getByHandle('autonav');
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'top';
$nav->controller->displaySubPages = 'all';
$nav->controller->displaySubPageLevels = 'custom';
$nav->controller->displaySubPageLevelsNum = 1;
$nav->render('view');
?>


but this shows all children no matter what level of the nav I am in, I tried changing the 'displaySubPages' to 'enough' and 'enought_plus1' but that did not work either. Any help would be most appreciated.

 
pvernaglia replied on at Permalink Reply
pvernaglia
You need some javascript do a drop down type of menu. There are a couple menus in the marketplace that will do it for you:

http://www.concrete5.org/marketplace/addons/ukao-menu/...
http://www.concrete5.org/marketplace/addons/superfish/...
alpdog14 replied on at Permalink Reply
So you are telling me that I have to pay for this type of functionality? Isn't there any solution where I can code this functionality in.
pvernaglia replied on at Permalink Reply
pvernaglia
You need javascript/CSS to hide the child menu items when you don't want them displayed, then when you click or hover on the parent you need javascript to turn those elements on.

If you search around you can find examples of the javascript that would need to make a drop down menu. If you do not know how to do that with javascript the quickest/easiest way to do it is to buy one of the menu add ons that have the functions you need.
jordanlev replied on at Permalink Reply
jordanlev
I'm not entirely clear on what the problem you're having is -- is your issue that you know how to make a dropdown menu but the wrong pages are showing up in that menu, or is the problem that you don't know how to create a dropdown menu with HTML/CSS? Or something else?
alpdog14 replied on at Permalink Reply
I basically want to show the children of a specific parent item but only if it is clicked on. I found this code:

<?php
$nav = BlockType::getByHandle('autonav');
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'top';
$nav->controller->displaySubPages = 'all';
$nav->controller->displaySubPageLevels = 'custom';
$nav->controller->displaySubPageLevelsNum = 1;
$nav->render('view');
?>

But this shows the children always, I want to show the children only when that parent is clicked on, also want the children to stay on if one of the children are clicked on. I was able to get this to work, kinda with the page type but would like to use the code above to do this. Hope this makes a little more sense.
Responsive replied on at Permalink Reply
Responsive
you mean a dropdown likehttp://twitter.github.com/bootstrap/components.html#navbar.... in the Navbar example ?
jordanlev replied on at Permalink Reply
jordanlev
So the problem here is that modern websites are generally constructed in a way where the HTML (which determines the "content" -- e.g. the links to pages that make up the nav menu) are isolated from the CSS (which determines the "design" -- e.g. what the menu links look like visually), and then that is itself isolated from the Javascript (which determines the "functionality" -- e.g. how the dropdown menus appear and disappear when clicked on).

The code you've pasted above for the autonav menu *only* applies to the HTML (the "content" portion of the equation). Concrete5 does not provide the actual design or functionality of the dropdown menus -- only the underlying HTML that shows which menu items are to be listed. You as the designer need to make it look a certain way and function a certain way. If you don't know how to do this or don't want to spend the time to do this, then you can either use a theme from the marketplace that included this kind of menu functionality, or use one of the addons from the marketplace that gives you this functionality (I know that the SuperFish addon does this, and there are probably other ones as well).

Hope that explains things a little better.
alpdog14 replied on at Permalink Reply
I do understand this completely now, thanks for clarifying, I found a great tutorial that I am going to attempt to implement.

http://www.concrete5.org/documentation/how-tos/developers/adding-a-...

wish me luck