如何对ExpressionEngine {reverse_related_entries}进行分页

Adr*_*eil 0 expressionengine

我很惊讶我以前没碰过这个,或者至少我忘记了我是如何工作的.

我有一个标准的EE关系领域.在这种情况下,我有一个"产品"频道,每个产品属于"设计师"频道中的一个条目.

我显然想要一个页面列出单个设计师的所有产品.我的第一次尝试看起来像这样:

{exp:channel:entries channel="designers" url_title="{segment_3}" limit="1"}

    {reverse_related_entries channel="products" limit="15"}
        {snippet_product_grid}
        {snippet_paginate}
    {/reverse_related_entries}

{/exp:channel:entries}
Run Code Online (Sandbox Code Playgroud)

根据EE文档中的轶事证据,您无法对反向相关条目进行分页.那么解决方案是什么?有没有办法轻松获取所有产品条目ID,给定url_title一个设计师?或者我是否必须使用SQL?

有什么方法可以使用Stash插件解决这个问题吗?

jan*_*nvl 5

你可以使用playa来建立你的人际关系.

据我所知,你应该能够在playa中对相关条目进行分页:https: //getsatisfaction.com/pixelandtonic/topics/pagination_in_playa#reply_6602199


Jér*_*upé 5

janvl用playa说的话.使用stash,你想使用Mark Croxton为{exp:stash:get_list}添加了分页功能的dev分支

https://github.com/croxton/Stash/tree/dev#expstashget_list-tag-pair

尚未在本地沙箱上测试此代码,但下面的代码应该可以帮助您入门

{exp:channel:entries channel="designers" url_title="{segment_3}" limit="1"}
    {exp:stash:set_list name="related_products" parse_tags="yes"}
        {reverse_related_entries channel="products"}
            {stash:st_item_title}{title}{/stash:st_item_title}
        {/reverse_related_entries}
    {/exp:stash:set_list}
{/exp:channel:entries}


{exp:stash:get_list name="related_products" parse_tags="yes" parse_conditionals="yes" prefix="my_prefix" paginate="bottom"}

    {if my_prefix:count == 1}<ul>{/if}
        <li>{st_item_title}</li>
    {if my_prefix:count == my_prefix:total_results}</ul>{/if}

    {if my_prefix:no_results}
        <p>No related products</a></p>
    {/if}

    {my_prefix:paginate}
        {pagination_links}
            <ul>
                {first_page}
                        <li><a href="{pagination_url}" class="page-first">First Page</a></li>
                {/first_page}

                {previous_page}
                        <li><a href="{pagination_url}" class="page-previous">Previous Page</a></li>
                {/previous_page}

                {page}
                        <li><a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
                {/page}

                {next_page}
                        <li><a href="{pagination_url}" class="page-next">Next Page</a></li>
                {/next_page}

                {last_page}
                        <li><a href="{pagination_url}" class="page-last">Last Page</a></li>
                {/last_page}
            </ul>
        {/pagination_links}
    {/my_prefix:paginate}

{/exp:stash:get_list}
Run Code Online (Sandbox Code Playgroud)