表达式引擎 - 特定类别中的下一个条目?
好的,表达式引擎的另一个问题。我很了解,但我只是在学习类别!
我四处寻找这个答案,但只能找到同样的东西。我需要在 title_permalink 页面上有一个下一个按钮,用于转到该类别中的下一个条目。我知道如何手动指定一个类别,但这不起作用,因为它只会给我该类别中的条目!我需要一种方法让 ee 知道该条目属于哪个类别。我的代码目前非常简单,它是:
{exp:channel:next_entry}<a href="{path='projects-test/view'}" style="color:#fff;">Next Project</a>{/exp:channel:next_entry}
我可以添加category_id =“2”,但是每当该人进入不是 2 的类别时会发生什么,它们都使用相同的视图模板。
我的结构如下:
类别选择页面 - 使用category_name标签的类别列表
项目列表页面 - 使用频道链接:条目标签
项目视图页面 - 通过 title_permalink 标签链接至此处
感谢您的帮助!
OK, another problem with Expression Engine. I know it pretty well but i'm sort-of just learning categories!
I've searched around for this answer but can only find the same thing. I need to have a next button on a title_permalink page that goes to the next entry in that category. I know how to manually specify a category but that won't work as it will only ever give me entries from that category! I need a way for ee to know what category the entry is in. My code is very simple at the moment, it's :
{exp:channel:next_entry}<a href="{path='projects-test/view'}" style="color:#fff;">Next Project</a>{/exp:channel:next_entry}
I could add category_id="2" but then what happens whenever the person goes into a category that isn't 2, they are all using the same view template.
My structure is like follows:
Category Selection page - list of categories using category_name tag
Project List page - links here using channel:entries tag
Project View page - linked here by a title_permalink tag
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认的 ExpressionEngine 下一个/上一个条目链接标记对允许您生成指向下一个或上一个条目,基于当前条目的日期。
然而,最大的限制是它们在限制或过滤具有多个类别的条目时不够强大。。
如果您的需求很简单,您可以使用以下代码来限制上一个/下一个链接以显示当前条目类别中的条目:
您会注意到
{exp:channel:prev_entry}
和 < code>{exp:channel:next_entry} 链接嵌套在{exp:channel:entries}
标记内,并使用{categories}
标记对进行限制下一个/上一个链接当前条目的类别。但请注意,当使用单个类别对条目进行分类时,此代码效果最佳。
否则,当对具有多个类别的条目使用
{categories}
标记对时,上一个/下一个链接将默认为第一个类别输出...这可能与下一个或上一个条目的顺序不同的类别。要获得更强大的解决方案,您会发现有许多第三方解决方案 在 Devot-ee 上用于条目链接。
我最喜欢的两个用于处理链接条目的插件是 Adam Khan 的 附近条目 和 条目列表,作者:Laisvunas。
The default ExpressionEngine Next/Previous Entry Linking Tag Pairs allow you to generate links to the next or previous entry, based on the date of the current entry.
However, the biggest limitation is that they not as robust when it comes to restricting or filtering entries with multiple categories.
If your needs are simple, you can use the following code to restrict the Previous/Next links to showing entries within the current entry's category:
You'll notice that the
{exp:channel:prev_entry}
and{exp:channel:next_entry}
links are nested inside the{exp:channel:entries}
tag and use the{categories}
tag pair to restrict the Next/Previous links to the current entry's category.Realize, however, that this code works best when entries are classified using a single category.
Otherwise, when using the
{categories}
tag pair with an entry having multiple categories, the Previous/Next links will default to the first category output ... which may be different than the next or previous entry's order of categories.For a more robust solution, you'll find there are many third-party solutions on Devot-ee for entry linking.
Two of my favorite plugins for handling linked entries are Nearby Entries by Adam Khan and Entries List by Laisvunas.