Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
表达式引擎-如果url中不存在url\u标题,则显示默认条目_Url_Title_Expressionengine - Fatal编程技术网

表达式引擎-如果url中不存在url\u标题,则显示默认条目

表达式引擎-如果url中不存在url\u标题,则显示默认条目,url,title,expressionengine,Url,Title,Expressionengine,Dynamic设置为on,这样它将显示url\u标题作为url最后一段出现的条目。一切正常 我还有一个索引页面(作为频道条目),其url\u标题为“索引页面”。但是我希望这个页面在默认情况下显示,而不必显示最后一个url段。有没有一种方法可以做到: {exp:channel:entries dynamic="yes" limit="1"} // some code {/exp:channel:entries} 花了最后一个小时在谷歌上搜索,但毫无结果 谢谢。是否使用嵌入式系统 第一个模板

Dynamic设置为on,这样它将显示url\u标题作为url最后一段出现的条目。一切正常

我还有一个索引页面(作为频道条目),其url\u标题为“索引页面”。但是我希望这个页面在默认情况下显示,而不必显示最后一个url段。有没有一种方法可以做到:

{exp:channel:entries dynamic="yes" limit="1"}
   // some code
{/exp:channel:entries}
花了最后一个小时在谷歌上搜索,但毫无结果

谢谢。

是否使用嵌入式系统

第一个模板(通过url\u标题捕获您的正常页面:

{exp:channel:entries dynamic="yes" default_url_title="index_page" limit="1"}
  // some code
{/exp:channel:entries}
第二个模板-模板组/模板(此模板捕获第一页的索引):

另一种方法是使用URL段,而不是使用嵌入(因为它们会减慢ExpressionEngine的速度())

例如,如果您使用的url_标题位于段_2中,您可以执行以下操作:

{exp:channel:entries dynamic="no" url_title="index_page"}
   // some code
{/exp:channel:entries}
{if segment_2==“”}
{exp:channel:entries dynamic=“no”url\u title=“index\u page”}
//一些代码
{/exp:channel:entries}
{if:else}
{exp:channel:entries dynamic=“yes”limit=“1”}
//一些代码
{/exp:channel:entries}
{/if}
在else子句中,我仍然希望手动将url_title参数解析为url_title=“{segment_2}”…但这只是我自己。

{if segment_2==”“}
{if segment_2 == ""}

    <!-- So this is your default index page -->
    {exp:channel:entries dynamic="no" url_title="index_page"}
        // some code
    {/exp:channel:entries}

{if:else}

    <!-- And this is all the other pages -->
    {exp:channel:entries dynamic="yes" limit="1"}
    // some code
    {/exp:channel:entries}

{/if}
{exp:channel:entries dynamic=“no”url\u title=“index\u page”limit=“1”} {if:else} {exp:channel:entries dynamic=“yes”limit=“1”} {/if} //一些代码 {/exp:channel:entries}
谢谢你的回答,James。很抱歉回复太晚。这是一种冗长的方式……看起来EE确实需要一个“默认url\u title”参数,以便在缺少相关url段时与dynamic=yes一起使用……谢谢
{if segment_2 == ""}

    <!-- So this is your default index page -->
    {exp:channel:entries dynamic="no" url_title="index_page"}
        // some code
    {/exp:channel:entries}

{if:else}

    <!-- And this is all the other pages -->
    {exp:channel:entries dynamic="yes" limit="1"}
    // some code
    {/exp:channel:entries}

{/if}
{if segment_2 == ""}
    <!-- So this is your default index page -->
    {exp:channel:entries dynamic="no" url_title="index_page" limit="1"}
{if:else}
    <!-- And this is all the other pages -->
    {exp:channel:entries dynamic="yes" limit="1"}
{/if}

    // some code
{/exp:channel:entries}