Closed worfoual closed 9 years ago
You could create a template in your templates/_includes directory named (e.g.:) subnav.twig, with the following code:
{% if startFromId is defined %}
{{ craft.amNav.getNav("mainMenu", {
id: 'sidenav',
class: 'sidenav',
startFromId: startFromId
}) }}
{% endif %}
In your templates you call this twig template by using the following code:
{% include '_includes/subnav' with { startFromId: PAGE_ID_HERE } %}
You insert the required page ID at PAGE_ID_HERE. As an admin, you can see a button Display page IDs while you are building a navigation. When you use it, you can see the required page ID from here.
Thank you for your feedback, it's working. I have just 2 remarks, may be it can be useful for you. 1- When I am on the second level the first level is "losing" his class active 2- If I have something like that: level 1a -sub level -sub level level 1b -sub level And all this page are using the same template then I won't be able to use your code. I will have to make identical seperate template.
@hubertprein for your example, how would one go about getting page ID dynamically from say the active page?
@sg-modlab You can now use the latest version for that. You can get the active page ID using the new getActivePageIdForLevel function, and then use that page ID to build your navigation using the startFromId parameter.
This sounds great. Look forward to checking it out shortly and thanks.
Seth
On Thu, Dec 11, 2014 at 10:31 AM, Hubert Prein notifications@github.com wrote:
@sg-modlab https://github.com/sg-modlab You can now use the latest version for that. You can get the active page ID using the new getActivePageIdForLevel function, and then use that page ID to build your navigation using the startFromId parameter.
— Reply to this email directly or view it on GitHub https://github.com/am-impact/amnav/issues/5#issuecomment-66635483.
seth giammanco seth@mod-lab.com ph 718.858.1066
minds on design lab www.mod-lab.com Subscribe to our Mailing List https://confirmsubscription.com/h/y/12431274F3870FEA
I can display the level 1 of my menu in the header but I can't/don't know how to display the level 2, level 3... from the (active)level 1 in a sidebar.
In my header I have:
{{ craft.amNav.getNav("mainMenu", { maxLevel: '1', classActive: 'active', excludeUl: '1' }) }}
How do I get the level 2, level 3 from (active)level 1 in a sidebar? In your parameters I see this one: startFromId but I think I should need something like this: startFromLevel.
Sorry for my poor english. Francois