Render View in a other View
#1
Posted 13 April 2009 - 04:52 AM
I've a little question.
Is it possible to render in a view an other view?
What is the best way?
The problem is, that i try to include the "admin" view from an other controller in the form view...
When I do this with renderPartial() it have of course a error:
Fatal error: Call to a member function link() on a non-object
I understand why this can't work but how can i get this work?
With the runController Function I've the problem that it renders the whole layout.
Thank you for help,
sorry for my english
Greetings gartenschlauch
#2
Posted 13 April 2009 - 05:52 AM
#3
Posted 13 April 2009 - 07:07 AM
I'm using the newest version (1.0.4) but i think this problem is still here.
I want to create an Item (localhost/index.php?r=item/create)
In the _form.php i try to render the adminSite form an other Item
$this->renderPartial("/otherItem/admin");
but when i do this tehre is this error:
Fatal error: Call to a member function link() on a non-object in
Is this a bug?
#5
Posted 13 April 2009 - 08:01 AM
In the browser:
Fatal error: Call to a member function link() on a non-object in *pathToSite*\protected\views\otherItem\admin.php on line 10
an on line 10 is:
<th><?php echo $sort->link('parameter'); ?></th>
#6
Posted 13 April 2009 - 08:07 AM
#7
Posted 13 April 2009 - 08:39 AM
next time i will try to turn on my brain...
thanks for your help.
gartenschlauch
#8
Posted 14 April 2009 - 01:33 PM
I've a question again and it's about the same topic, so I hope it's okay when i use this thread again.
When i rendered the AdminView from the otherItem, can I use a linkButton to fire an event in the otherItemController?
Before it was like this:
echo CHtml::linkButton('Delete',array(
'submit'=>'',
'params'=>array('command'=>'delete','id'=>$model->id),
'confirm'=>"Are you sure to delete #{$model->id}?")); ?>But what do I've to change, respectively is it possible?
Do i have to catch this command in the ItemController and then redirect it to the otherItemController?
or should i use a default link?
Thank you for help again
gartenschlauch
#9
Posted 27 April 2009 - 02:12 PM
I would like to do something similar. I want to render collection of other controllers view results on my current controller, but it seems to not be working.
[code=I'm trying to do something like this]for (..)
{
$newForms[] = TheOtherController::renderPartial('create',array('TheOther'=>$TheOther),true);
}
$this->render('create',array('item'=>$item,'newForms'=>$newForms));
[/code]
I would like to make one entity with some collection items, sadly active record and views doesn't support such features.. Can anyone suggest me what to do?
#10
Posted 28 April 2009 - 01:25 PM
What is the correct way to get rendered information from another Controller?, how to use that controller? Is it posible?
#11
Posted 30 April 2009 - 04:19 PM
how do i query one entry for one of my models?
working through the Blog tutorial has been cool, but I am trying to expand my ability to be flexible with this
for instance:
i have my post model, and i want one of my entries in this model on my index page - how would I go about doing this?
i am fairly certain that it has something to do with render partial, and i am thinking that i need to send some values to the view that i include, but i cant completely figure that out -
basically - i was trying to pull something like this:
i created the _show.php file in my post views but i have no idea how to get this party started
any tips?
say for example that the id for my post is '9' - i want this one to appear somewhere
any tips?
Thanks
Peace
#12
Posted 30 April 2009 - 04:21 PM
#13
Posted 30 April 2009 - 04:38 PM
how would i specify which post i want to display tho?
i dont want to display every entry in my Model table - just one specific entry
like for example - if the id of the post i want to display is '9'
would i do something like this?
also
when i used that snippet of code, it still comes back telling me that
post is the model name
thanks for the help
#14
Posted 30 April 2009 - 06:59 PM
#16
Posted 05 May 2009 - 03:48 PM
how would you do the same thing, but within a module -
basically - getting a renderPartial from a view outside a module, and include it in one of the views in the module
example:
this piece of code works in my application:
$static = Global_content::model()->findByPk(2);
$this->renderPartial('/global_content/_show',array(
'static'=>$static,
));
but it does not work when i try to use it inside my module
error:
DefaultController cannot find the requested view "/global_content/_show".
#17
Posted 25 June 2009 - 03:41 AM
@admin : please answer this question : can we use renderPartial in module ?
#18
Posted 25 June 2009 - 09:12 AM
#19
Posted 25 June 2009 - 09:43 AM
Quote
Why not just use a widget?
#20
Posted 29 June 2009 - 11:32 AM
Quote
hmm... interesting -
can you explain the bad-practiceness of this?
thanks man

Help

This topic is locked










