I’m using the user module to provide simple user management. The user module provides a “login” view. I want to render the login view so I can show the view inside a modal dialog (in a similar manner to stay.com).
What’s the correct approach to rendering a modules view like this? I’ve tried calling render with the modules view name from inside an application view and inside a simple widget I created. No matter what path I provide to the view e.g. “/module/user/views/user/login” I can’t get the view to render.
Thanks, that doesn’t really answer the question though. That article is rendering the application view “login”, I’m trying to explicitly render a view that’s contained within a module. I assumed that appending the module path in front of the view e.g. “/module/user/views/user/login” would render the view but it doesn’t.
Sounds like what you need is a login widget. This widget could even be packaged with the user module. Controller actions are not meant to be embedded in other actions except via AJAX. Widgets are meant to be embedded though
Thanks for the reply. My original approach was to create a login / register widget which was modelled on the stay.com widget. There were two problems with using a widget though (that wasn’t packaged as part of the user module). Firstly I couldn’t get renderpartial to work, then I couldn’t get the view name to work as I’ve outlined above (I just resorted to using render at this point).
Please tell me what I’m doing wrong. The only approach I can see working at the moment is to use the model and controller from the “user” module and create a view inside the widget - that seems completely wrong though.
I’m try to find solution for similar functionality. Looking to create login window using zii.widgets.jui.CJuiDialog
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'mydialog',
// additional javascript options for the dialog plugin
'options'=>array(
'title'=>'Please login',
'autoOpen'=>true,
),
));
//echo 'dialog content here';
$this->renderPartial('/site/pages/about'); // works fine. this is a static page without model
//$this->renderPartial('/user/login'); // Don't work
//$this->renderPartial('/site/contact'); // Also don't work with error Undefined variable: model.
$this->endWidget('zii.widgets.jui.CJuiDialog');
// the link that may open the dialog
echo CHtml::link('open dialog', '#', array(
'onclick'=>'$("#mydialog").dialog("open"); return false;',
));
?>
Any ideas how I can use CJuiDialog to render other controllers view?
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'mydialog',
// additional javascript options for the dialog plugin
'options'=>array(
'title'=>'Please login',
'autoOpen'=>true,
),
));
//define the model
$model= new loginForm;
//echo 'dialog content here';
$this->renderPartial('/user/login',array('model'=>$model));
$this->endWidget('zii.widgets.jui.CJuiDialog');
// the link that may open the dialog
echo CHtml::link('open dialog', '#', array(
'onclick'=>'$("#mydialog").dialog("open"); return false;',
));
?>