gpt4 book ai didi

expressionengine - 在expressionengine中设置自定义模板变量

转载 作者:行者123 更新时间:2023-12-04 03:30:21 24 4
gpt4 key购买 nike

我需要在条目的模板中多次输出条目的类别。

因此,我想从以下代码中获取输出并分配给变量,以便可以在模板中重用:

{exp:channel:entries channel="product" limit="1" status="open"}
{categories}{category_name}{/categories}
{/exp:channel:entries}"

它是如何做到的?

最佳答案

现在,您可以启用模板以允许PHP,然后可以编写如下代码:

{exp:channel:entries channel="product" limit="1" status="open"}
{categories}
<?php $category = '{category_name}'; ?>
{/categories}
{/exp:channel:entries}

然后,您将 {category_name}存储在php变量“category”中。稍后,您可以根据需要重复使用它,例如回显它:
<?php echo $category; ?>

您甚至可以将其与其他EE标签进行比较:
{exp:channel:entries channel="product" limit="1" status="open"}
{if <?php $echo($category) ?> == title}
This title have got the same value as the category!
{/if}
{/exp:channel:entries}

关于expressionengine - 在expressionengine中设置自定义模板变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7549372/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com