在我的自定义组件中......
country
,可以显示该国家/地区的人员列表(查看:人员)。 dog
来完成。 任务
在人物视图中,我想根据国家或狗是否设置为过滤器来显示标题,例如“奥地利”或“有狗的人”。
我尝试了什么......
从我的view-object读取活动过滤器会将两个过滤器返回为1
,即使它未设置:
["filter.country"]=>int(1)
["filter.dog"]=>int(1)
["list.limit"]=>string(2) "20"
(...)
我的模型文件(摘录):
protected function populateState($ordering = null, $direction = null) {
$app = JFactory::getApplication();
$country = $this->getUserStateFromRequest($this->context.'.filter.country', 'country', '', null, false);
$this->setState('filter.country', (int) $country);
$dog = $this->getUserStateFromRequest($this->context.'.filter.dog', 'dog', '', null, false);
$this->setState('filter.dog', (int) $dog);
(...)
parent::populateState($ordering, $direction);
}
编辑:
public function __construct($config = array()) {
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'country',
'dog'
);
}
parent::__construct($config);
}
view.html.php:
public function display($tpl = null) {
$app = JFactory::getApplication();
$this->state = $this->get('State');
(...)
我迷路了 - 从状态中读取信息是否无意义,或者我的过滤器设置不正确?