joomla 1.5 多个模型,默认视图问题
我正在开发一个需要重用模型的视图,我正在遵循此文档 http://docs.joomla。 org/Using_multiple_models_in_an_MVC_component。但是当我使用参数获取任务时,该引用就起到了作用(至少据我所知)。如果我使用该视图,joomla 会给我空数据。
更清楚的是
controller.php - 我命名为视图的任务我需要
function viewdowhatIneed(){
$view = & $this->getView('viewdowhatIneed',html);
$view->setModel( $this->getModel( 'thenotdefaultmodelthatIneed' ), true );
$view->display();
}
模型 - thenotdefaultmodelthatIneed.php
class BLAModelthenotdefaultmodelthatIneed extends Jmodel{
function getReusableData0(){...}
function getReusableData1(){...}
}
视图 - view.html.php
class BLAViewviewdowhatIneed extends JView{
function display($tpl=null){
$dataneedit0 = $this->get('ReusableData0');
$dataneedit1 = $this->get('ReusableData1');
$this->assignRef('dataneedit0',$dataneedit0);
$this->assignRef('dataneedit1',$dataneedit1);
parent::display($tpl);
}
}
所以,发生在我身上的是:
example.com/index.php?option=com_BLA&view=viewdowhatIneed ->变量(datadataneedit0,dataneedit1) == NULL
example.com/index.php?option=com_BLA&task=viewdowhatIneed ->变量(datadataneedit0,dataneedit1)==然后给我正确的数据
,我的问题是,有没有办法通过使用没有任务参数的视图参数来完成同样的事情(顺便说一句,我知道这可能不是一个重要的问题,但我我不是专家,对此参考http://docs.joomla.org/How_Joomla_pieces_work_together,它说:
任务部分可能存在,也可能不存在。请记住,如果省略它,则默认为 task=display
所以我真的很想知道这一点。换句话说,我的视图是否可以强制检查控制器,反之亦然。
预先感谢,请原谅我的英语
I'm developing a view that need to reuse a model, I'm following this documentation http://docs.joomla.org/Using_multiple_models_in_an_MVC_component. But that reference do the trick just (at least as far as I understand) when I use the parameter get task. if I use the view, joomla get me null data.
more clearly
controller.php - the task I named as the view I need
function viewdowhatIneed(){
$view = & $this->getView('viewdowhatIneed',html);
$view->setModel( $this->getModel( 'thenotdefaultmodelthatIneed' ), true );
$view->display();
}
model - thenotdefaultmodelthatIneed.php
class BLAModelthenotdefaultmodelthatIneed extends Jmodel{
function getReusableData0(){...}
function getReusableData1(){...}
}
view - view.html.php
class BLAViewviewdowhatIneed extends JView{
function display($tpl=null){
$dataneedit0 = $this->get('ReusableData0');
$dataneedit1 = $this->get('ReusableData1');
$this->assignRef('dataneedit0',$dataneedit0);
$this->assignRef('dataneedit1',$dataneedit1);
parent::display($tpl);
}
}
SO, what happen to me is:
example.com/index.php?option=com_BLA&view=viewdowhatIneed -> variables(datadataneedit0,dataneedit1) == NULL
example.com/index.php?option=com_BLA&task=viewdowhatIneed -> variables(datadataneedit0,dataneedit1) == Get me right data
then, my question is, is there a way to do the same thing, by using view parameter without task parameter (btw, I know this could be not a important problem, but I'm not an expert and on this reference http://docs.joomla.org/How_Joomla_pieces_work_together, it says:
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display
so I really want to know that. In other words, can my view force to check the controller or vice versa.
Thanks in advance, excuse my english
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论