ListChildren递归地输入

问题描述 投票:3回答:1

有一种Page接口的方法可以用来轻松迭代子进程。

我想以递归方式迭代所有后续子节点。

有一个重载方法listChildren(Filter,Boolean)可以做到这一点......如何从这个方法调用这个方法?我的意思是如何修改上面提到的标签以递归方式执行。

recursion cq5 aem sling sightly
1个回答
14
投票

你可以定义一个data-sly-template,它是某种宏,然后用data-sly-call递归调用它:

<template data-sly-template.descendants="${@ page}">
    ${page.title}
    <ul data-sly-list.child="${page.listChildren}">
      <li data-sly-call="${descendants @ page=child}"></li>
    </ul>
</template>

<div data-sly-call="${descendants @ page=currentPage}" data-sly-unwrap></div>
© www.soinside.com 2019 - 2024. All rights reserved.