我正在 Joomla 后端对表格列进行排序。我根据本教程调整设置。
正如我们所见,建议覆盖populateState方法并手动获取排序选项。
public function populateState() {
$filter_order = JRequest::getCmd('filter_order');
$filter_order_Dir = JRequest::getCmd('filter_order_Dir');
$this->setState('filter_order', $filter_order);
$this->setState('filter_order_Dir', $filter_order_Dir);
}
Run Code Online (Sandbox Code Playgroud)
但是我注意到本机组件com_content没有在模型文件中明确设置这些选项administrator/components/com_content/models/articles.php。
protected function populateState($ordering = null, $direction = null)
{
// Initialise variables.
$app = JFactory::getApplication();
$session = JFactory::getSession();
............................................
............................................
............................................
// List state information.
parent::populateState('a.title', 'asc');
}
Run Code Online (Sandbox Code Playgroud)
相反,它只是调用 parent populateState。事实上JModelList::populateState()包括这个:
protected function populateState($ordering = null, $direction = null)
{
// If the context is set, assume that stateful …Run Code Online (Sandbox Code Playgroud) var x = 9;
var mod = {
x: 81,
assign: function(){
this.x = 9;
x = 3;
},
checkVars: function(){
alert(x + " - " + this.x );
}
};
mod.checkVars(); //9 - 81
mod.assign();
mod.checkVars(); //3 - 9
alert(x); //3
Run Code Online (Sandbox Code Playgroud)
请解释范围链如何在这里设置自己.为什么范围解析为xin checkVars和assignskip对象mod?