我想在我的 ExpressionEngine 模板中使用一些存储的 cookie 值,而不使用任何 PHP。
我当前的模板代码
{exp:channel:entries channel="favorites" category="<?php echo $COOKIE['favorite']?>"}
{title}
{/exp:channel:entries}
这很丑陋,并且在负载下表现不佳。 有什么建议么?也许是一个插件?
最佳答案
您必须使用 Functions 类中的 set_cookie() 方法在 EE 中设置 cookie。
$this->EE->functions->set_cookie('your_cookie_name', 'some_value', 3600 * 24) // Set a cookie that expires in 1 day
$this->EE->input->cookie('your_cookie_name'); // returns 'some_value';
来自 Devot:ee 的 EE 插件
关于expressionengine - 获取 cookie 值并在 ExpressionEngine 模板中使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13241672/