首页 > 解决方案 > 无法访问 magnolia cms 中的链接和子页面

问题描述

所以我想从子页面的子页面访问一个链接(孙子?我不知道它的名字对不起)。如图所示

页面图片

我已经尝试过使用这段代码,但这并没有让我到达我想要的地方。它属于孩子,所以只有一层。

[#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] 

先感谢您

标签: javafreemarkermagnolia

解决方案


据此,_

depth == 1 将根页面返回到此页面,depth == 2 将返回根页面的子页面,依此类推。

所以也许你想要

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

代替

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

我认为无论如何都是令人困惑的。一个节点的“祖先”应该沿着树向上传播,而不是沿着它向下传播。也许它应该是“后裔”。


推荐阅读