【发布时间】:2013-02-20 11:46:02
【问题描述】:
我编写了以下 PHP 函数,用于根据段 3 URL 返回当前类别。
<?php
$this->EE =& get_instance();
$seg3 = $this->EE->uri->segment(3);
$categoriess = getCategory($seg3);
function getCategory($string)
{
switch ($string)
{
case "test1": return '16';
case "test2": return '52';
case "test3": return '18';
case "test4": return '29';
case "test5": return '37';
}
return '11';
}
?>
<?php echo $categoriess; ?>
好吧,该函数完成了这项工作并返回了正确的数字。问题在于调用类别标签中返回的数字。
{exp:channel:entries channel=“news” dynamic=“no” category=”<?php echo $categoriess; ?>” orderby=“entry_date” disable=“member_data|trackbacks” sort=“desc” limit=“5”}
在我看来一切都是正确的,但它就是行不通…… 非常感谢您的帮助!
谢谢!
【问题讨论】:
-
Wtf 是那些引号?
“test5”,‘37’?像这样写:case "test5": return 37; -
语法错误,如果我从返回中删除引号会出现意外的 T_LNUMBER
-
从什么时候返回通常的整数应该是错误的?
标签: php tags categories expressionengine