帝国CMS按栏目ID调用对应栏目字段信息方法
-
添加自定义函数:
function class_field($classid, $field) { global $empire, $dbtbpre; $classid = (int)$classid; $arr = array('classname', 'bname', 'classimg', 'classpagekey', 'intro'); if (!in_array($field, $arr)) { return FALSE; } if (!$classid || !$field) { return FALSE; } else { $class_sqls = $empire->fetch1("select " . $field . " from " . $dbtbpre . "enewsclass where classid=" . $classid); return $class_sqls[$field]; } }
-
模板中调用:
<?=class_field(栏目id, '字段名称')?>