Sulu:如何使用智能内容实现“加载更多”按钮?

问题描述

所以我这样定义我的字段:

    <property name="news" type="smart_content">
        <!-- @see https://docs.sulu.io/en/2.2/reference/content-types/smart_content.html -->
        <meta>
            <title lang="en">News</title>
            <title lang="de">Nachrichten</title>
        </meta>

        <params>
            <param name="provider" value="articles"/>
            <param name="types" value="news"/>
        </params>
    </property>

我的树枝模板看起来像:

<div>
    {% for article in news %}
        <a href="{{ sulu_content_path(article.routePath) }}" >
            <h2>
                {{ article.excerpt.title|default(article.title) }}
            </h2>
        </a>
    {% endfor %}
</div>

它抓取“新闻”类型的文章,效果很好。现在我需要实现“加载更多”类型的寻呼机。所以我应该在开始时显示 5 篇最新文章,然后点击它们“加载更多”按钮,当点击另外 5 篇时,应该加载另外 5 篇,然后再点击 5 篇等等,直到有可用的新闻文章。我在 sulu 文档中没有看到任何地方提到“加载更多”功能。

实现这一目标的最佳方法是什么?

解决方法

我不久前创建了一个 github gist,展示了它是如何工作的。 见https://gist.github.com/luca-rath/d16c0ad74fa06da49fed22404a53398b

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...