Lwent
Lwent

Reputation: 1

Cannot access links and child pages in magnolia cms

So I want to access a link from a child of a child page(grandson? I don't know the name for it sorry). As the image shows

Image of the pages

I've tried with this code but that doesn't get me where I want. It goes to child, so just one level down.

[#assign subNavigationRootPage = navfn.ancestorPageAtLevel(content, 2)!]
    [#if subNavigationRootPage??]
       [#assign navItems = navfn.navItems(subNavigationRootPage)]
       [#list navItems as navItem]
          <a class="btn btn-secondary" href="${cmsfn.link(navItem)!}?id=${producto.id}" role="button">Ver detalles</a>
       [/#list]
    [/#if] 

Thank you in advance

Upvotes: 0

Views: 250

Answers (1)

Bradley Andersen
Bradley Andersen

Reputation: 311

According to this,

depth == 1 would return the root page to this page, depth == 2 would return the child page of the root page, etc.

So maybe you want

[#assign subNavigationRootPage = navfn.ancestorPageAtLevel(content, 3)!]

instead of

[#assign subNavigationRootPage = navfn.ancestorPageAtLevel(content, 2)!]

I think it's confusing in any case. The 'ancestor' of a node should travel up the tree, not down it. Maybe it should rather be 'descendent'.

Upvotes: 1

Related Questions