在 ExpressionEngine (1.6.x) 中自定义单条目模板

发布于 2024-09-16 02:15:10 字数 273 浏览 4 评论 0原文

这要么非常烦人,要么非常尴尬。我已经设置了博客的大部分内容,但我不知道在哪里或如何设置单个条目模板,而不是包含它们的部分/博客。我只是找不到关于如何在我的一生中做到这一点的信息。

这一点尤其重要,因为我想为所有条目定义规范链接,因为 ExpressionEngine 以各种方式链接到条目。

因此,情况是我有一个博客部分/博客,其索引用作 mydomain.com 的首页。这列出了我的所有条目,就像您想象的普通博客一样。当我需要为单个条目的链接自定义代码时,问题就出现了。

This is either very annoying or very embarrassing. I've set up most of my blog, but I can't figure out where or how the heck I set up single entry templates as opposed to the section/weblog containing them. I just can't find information on how to do it for the life of me.

This is especially important, because I want to define the canonical link for all entries, since ExpressionEngine links to entries in all kinds of ways.

So, the case is that I have a Blog section/weblog with an index working as the front page for mydomain.com. This lists all my entries as you would imagine a regular blog to do. The problem arises when I need to customize the code for the single entries' links.

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

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

发布评论

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

评论(1

强辩 2024-09-23 02:15:10

如果您已经设置了一个显示多个条目的模板,并且您希望每个条目都有一个条目页面,那么您需要做的是:

{exp:channel:entries
channel="default_site"
sort="asc"
disable="member_data|pagination|categories"}

<a href="{url_title_path="template_group/template_name"}" title="{title}">{title}</a>

{/exp:channel:entries}

然后在上面显示的模板中通过 template_group/template_name (请将它们更改为任何内容)您的模板组和模板名称实际上是;-))您将放置此代码:

{exp:channel:entries
channel="default_site"
limit="1"
dynamic="yes"
sort="asc"
disable="member_data|pagination|categories"}

{title}

{/exp:channel:entries}

然后,这将仅向您显示一个条目,因为您将在上面的第一个频道条目标签中使用 {url_title_path="template_group/template_name"}基本上会创建一个类似这样的URI:

http://www.example.com/template_group/template_name/ url_title_of_my_posted_entry

在第二个 (template_group/template_name) 单条目模板页面上,它将看到 URL 标题,并使用它来将频道条目标记过滤到仅该条目。

希望能有所帮助。

最好的祝愿,

If you have a template set up already which is showing a multitude of entries and you want a single entry page for each entry then what you need to do is this :

{exp:channel:entries
channel="default_site"
sort="asc"
disable="member_data|pagination|categories"}

<a href="{url_title_path="template_group/template_name"}" title="{title}">{title}</a>

{/exp:channel:entries}

Then in the template shown above by template_group/template_name (please change those to whatever your template group and template names actually are ;-) ) you will place this code :

{exp:channel:entries
channel="default_site"
limit="1"
dynamic="yes"
sort="asc"
disable="member_data|pagination|categories"}

{title}

{/exp:channel:entries}

This will then show you just the one entry as you will have used the {url_title_path="template_group/template_name"} in the first channel entries tag above which would basically create a URI something like this :

http://www.example.com/template_group/template_name/url_title_of_my_posted_entry

On the second (template_group/template_name) single entry template page it will see the URL title and use this to filter down the channel entries tag to just that one entry.

Hope that helps a bit.

Best wishes,

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