让我澄清一下:我正在构建一个相对简单的宣传册网站,其中有多个部分,我想使用相同的“模板”。例如:http://example.com/section1& http://example.com/section2。我还希望这两个部分为其各个条目页面使用相同的“视图”模板,例如http://example.com/section1/item1或http://example.com/section2/item2/。
这可能吗?我对EE&一直在阅读有关改变网址结构的许多方法,但没有什么比我要求的更好。我也知道我的解决方案可以通过创建两个具有相同索引模板的模板组来实现,但这看起来相当愚蠢。
P.S。我知道我的频道设置可能是相关的,所以请让我知道它们应该是什么,以便回答这个问题。
非常感谢
Zander的
答案 0 :(得分:3)
是的,这是可能的。签出页面模块。
页面模块允许您选择URL和模板。安装页面模块后,会在编辑屏幕上添加一个新的“页面”选项卡。确保您没有在{exp:channel:entries}标记对中将动态参数设置为“no”。
此问题还有其他解决方案,但这是最直接的。
答案 1 :(得分:3)
是的,这是可能的,你有几个选择。
首先是使用Structure。结构允许您跨多个页面使用相同的页面模板(即http://example.com/section1和http://example.com/section2)。这可能是你最好的选择。
第二个选项是使用ExpressionEngine附带的页面模块。
第三个选项是使您的索引模板成为一个简单的“路由器”。它会是这样的:
{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}
这将查看网址细分,然后为每个细分嵌入相同的模板,并将条目ID传递给您{exp:channel:entries}
标记,以显示相应条目中的内容。