ExpressionEngine 中的导航和分页问题

发布于 2024-11-13 06:28:05 字数 1390 浏览 3 评论 0原文

我建立了一个包含八个频道的网站,分为两个部分。

其中一个部分称为“文章”,该部分中有两个频道:“专题”和“新闻”。

一切都很顺利,直到我将分页引入方程中。

在文章索引页面上,我有“最新”、“特征”和“新闻”选项卡,我可以浏览它们并根据细分选择条目:

<ul id="tabs">
<li>{if segment_2 == ''}<strong>Latest</strong>{if:else}<a href="{site_url}articles/">Latest</a>{/if}</li>
<li>{if segment_2 == 'features'}<strong>Features</strong>{if:else}<a href="{path=articles/features}">Features</a>{/if}</li>                    
<li>{if segment_2 == 'news'}<strong>News</strong>{if:else}<a href="{path=articles/news}">News</a>{/if}</li>
</ul>
{if segment_2 == ''}{exp:channel:entries channel="features|news" limit="10" dynamic="no" order="date" paginate="both"}{/if}
{if segment_2 == 'features'}{exp:channel:entries channel="features" limit="10" dynamic="no" order="date" paginate="both"}{/if}                
{if segment_2 == 'news'}{exp:channel:entries channel="news" limit="10" dynamic="no" order="date" paginate="both"}{/if}  

site.com/articles 会显示所有条目
site.com/articles/features/ 显示功能频道中的所有条目
site.com/articles/news/ 会显示新闻频道中的所有条目

这非常有效,直到存在一个包含多个页面的频道并且将“P4”之类的内容添加到 URL 中,然后未过滤索引的 {segment_2} 变为 P4我正在做什么来导航频道条目。

分页网址: site.com/articles/P4

我想我的问题是这样的:

我是否正确导航或过滤条目?如果是这样,我现在该如何进行分页呢?

谢谢!

I’ve set up a site with eight channels divided into two sections.

One of the sections is called “Articles” and within that section there are two channels, “Features” and “News”.

Everything was working great until I introduced pagination into the equation.

On the Articles index page, I have tabs for “Latest”, “Features” and “News” and I navigate through them and select entries based on the segment:

<ul id="tabs">
<li>{if segment_2 == ''}<strong>Latest</strong>{if:else}<a href="{site_url}articles/">Latest</a>{/if}</li>
<li>{if segment_2 == 'features'}<strong>Features</strong>{if:else}<a href="{path=articles/features}">Features</a>{/if}</li>                    
<li>{if segment_2 == 'news'}<strong>News</strong>{if:else}<a href="{path=articles/news}">News</a>{/if}</li>
</ul>
{if segment_2 == ''}{exp:channel:entries channel="features|news" limit="10" dynamic="no" order="date" paginate="both"}{/if}
{if segment_2 == 'features'}{exp:channel:entries channel="features" limit="10" dynamic="no" order="date" paginate="both"}{/if}                
{if segment_2 == 'news'}{exp:channel:entries channel="news" limit="10" dynamic="no" order="date" paginate="both"}{/if}  

site.com/articles brings up all entries
site.com/articles/features/ brings up all entries in the Features channel
site.com/articles/news/ brings up all entries in the News channel

This works great until there is a channel with multiple pages and something like “P4” is added to the URL and then {segment_2} for the unfiltered index becomes P4 instead of what I am doing to navigate the channel entries.

Paginate URL:
site.com/articles/P4

I guess my question is this:

Am I navigating or filtering entries correctly? If so how would I do so now with pagination?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╄→承喏 2024-11-20 06:28:05

这里有两种可能的解决方案。

您可以使用 paginate_base 参数明确告诉 EE 使用特定路径在分页参数之前:

{if segment_2 == 'features'}{exp:channel:entries channel="features" limit="10" dynamic="no" order="date" paginate="both" paginate_base="articles/features"}{/if}                
{if segment_2 == 'news'}{exp:channel:entries channel="news" limit="10" dynamic="no" order="date" paginate="both" paginate_base="articles/news"}{/if}`

或者 - 我的首选解决方案 - 是在“文章”组下创建两个新模板,分别命名为“新闻”和“特征”,并在那里列出您的条目。您可以通过将选项卡导航(甚至您计划在 channel:entries 标记之间放置的标记/逻辑,如果每个部分都相同的话)转换为 片段

There are two possible solutions here.

You can use the paginate_base parameter to explicitly tell EE to use a specific path before the pagination argument:

{if segment_2 == 'features'}{exp:channel:entries channel="features" limit="10" dynamic="no" order="date" paginate="both" paginate_base="articles/features"}{/if}                
{if segment_2 == 'news'}{exp:channel:entries channel="news" limit="10" dynamic="no" order="date" paginate="both" paginate_base="articles/news"}{/if}`

Alternately - and my preferred solution - is to create two new templates under the "articles" group, named "news" and "features", and list your entries there. You can avoid any duplication of code by turning your tab navigation (and even the markup/logic you plan on placing between your channel:entries tags, if it will be the same for each section) into snippets.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文