【问题标题】:Yii - How do I access a view from a module in the applications SiteController?Yii - 如何从应用程序 SiteController 中的模块访问视图?
【发布时间】:2013-08-16 19:21:36
【问题描述】:

只是想知道我需要做什么才能访问我的 SiteController 类中的模块视图以呈现该视图而不是索引视图。我想访问在protected/modules/account/views/account/register.php 中找到的视图。我知道我需要在我的SiteController::actionIndex class::method:$this->render('index', array('model' => $model)); 中更改这一行。但我不确定我需要放什么才能访问模块的视图。我试过'account/views/account/register,但我得到了这个例外:CException SiteController cannot find the requested view "account\views\account\register"

感谢您提供的任何帮助或指导

【问题讨论】:

  • 你检查手册的模块部分了吗?
  • 请注意,如果您必须做这种事情,这通常是设计不太好的标志。模块应该是自包含的。永远不需要从外部访问模块视图。

标签: php templates yii scope yii-modules


【解决方案1】:

通过这个你可以访问 modules/mymodule/views/profile/changepassword 视图

$this->renderPartial('application.modules.mymodule.views.profile.changepassword',array('model'=>$model));

【讨论】:

  • 我收到了。你知道为什么吗?这是动作“索引”的视图内容。该动作属于“健身”模块中的控制器“健身控制器”。您可以通过编辑自定义此页面
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-01
  • 1970-01-01
  • 2014-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多