在ExpressionEngine 2中,是否可以使用相同的“页面”?多页模板?

发布于 2024-12-29 09:05:43 字数 659 浏览 3 评论 0原文

让我澄清一下:我正在构建一个相对简单的小册子网站,其中有多个部分,我想使用相同的“模板”。例如: http://example.com/section1 & http://example.com/section2。我还希望这两个部分对其各自的条目页面使用相同的“视图”模板,例如在 http:// /example.com/section1/item1http://example.com/section2/item2/< /a>.

这可能吗?我对 EE 和 EE 很陌生。已经阅读了很多更改 url 结构等的方法,但没有什么像我所要求的那样。我还知道我的解决方案可以通过创建两个具有相同索引模板的模板组来实现,但这似乎相当愚蠢。

PS 我知道我的频道设置可能相关,所以请让我知道它们应该是什么才能回答这个问题。

非常感谢

桑德尔

Let me clarify: I am building a relatively simple brochure site that has multiple sections that I would like to use the same 'template'. For example: http://example.com/section1 & http://example.com/section2. I would also like these two sections to use the same 'view' template for their individual entry pages, for example on http://example.com/section1/item1 or http://example.com/section2/item2/.

Is this possible? I am very new to EE & have been reading about lots of ways to change url structure etc but nothing quite like what I'm asking. I am also aware that my solution could be achieved by creating two template groups with identical index templates with them but that seems rather silly.

P.S. I know my channel settings might be relevant so please let me know what they should be in order to answer this.

Many thanks

Zander

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

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

发布评论

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

评论(2

瞎闹 2025-01-05 09:05:43

是的,这是可能的,并且您有几个选择。

第一种是使用 Structure。结构允许您在多个页面上使用相同的页面模板(即 http://example.com/section1 和 < a href="http://example.com/section2" rel="nofollow">http://example.com/section2)。这可能是您最好的选择。

第二种选择是使用 ExpressionEngine 附带的 Pages 模块。

第三个选项是使您的索引模板成为一个简单的“路由器”。它会是这样的:

 {if segment_2 == 'item1'}
     {embed="template_group/template_name" entry_id="4"}
 {if:elseif segment_2 == 'item2'}
     {embed="template_group/template_name" entry_id="3"}
 {if:elseif segment_1 == 'section2'}
     {embed="template_group/template_name" entry_id="2"}
 {if:elseif segment_1 == 'section1'}
     {embed="template_group/template_name" entry_id="1"}
 {/if}

这将查看 URL 段,然后为每个段嵌入相同的模板,并向其传递可在 {exp:channel:entries} 标记中使用的条目 ID显示相应条目的内容。

Yes, this is possible, and you've got a few options.

The first is to use Structure. Structure allows you to use the same page templates across multiple pages (ie http://example.com/section1 and http://example.com/section2). This is probably your best bet.

The second option is to use the Pages Module that comes with ExpressionEngine.

The third option is to make your index template a simple 'router'. It would go something like this:

 {if segment_2 == 'item1'}
     {embed="template_group/template_name" entry_id="4"}
 {if:elseif segment_2 == 'item2'}
     {embed="template_group/template_name" entry_id="3"}
 {if:elseif segment_1 == 'section2'}
     {embed="template_group/template_name" entry_id="2"}
 {if:elseif segment_1 == 'section1'}
     {embed="template_group/template_name" entry_id="1"}
 {/if}

This will look at the URL segments and then embed the same template for each, and pass it the entry ID which you can use in your {exp:channel:entries} tag to display the content from the appropriate entry.

深居我梦 2025-01-05 09:05:43

是的,这是可能的。检查页面模块。

页面模块将允许您选择 URL 和模板。安装后,页面模块将在编辑屏幕上添加一个新的“页面”选项卡。确保您没有在 {exp:channel:entries} 标记对中将动态参数设置为“no”。

这个问题还有其他解决方案,但这是最直接的。

Yes, this is possible. Checkout the Pages module.

The Pages module will allow you select the URL as well as the template. When installed the Pages module will add a new 'pages' tab to the edit screen. Make sure you are not setting the dynamic parameter to 'no' in your {exp:channel:entries} tag pair.

There are other solutions to this problem, but this is the most straight forward.

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