tags:

views:

291

answers:

2

I developed an application with different MVCs using the Yii Framework

For example

I created a crud layer for Student Contact details and Student Courses etc.

All worked perfectly since each had its own menu, and when clicked eachs own view rendered.

Now my client wants everything on one page, and is quite persistent, we are talking about 7 MVC that need to be displayed on one page. Each MVC has it's own controller, model and view and own DB table. How can I render all of them on one page without re-writing the whole application? Is this possible.

+1  A: 

If I understood your problem correctly, you simply want to merge all menu items and show the full navigation on each page.

By separating menus into standalone views and including each and one of them into a navigation view, you can have a well-structured non-repeating code.

$this->renderPartial('anotherView');

is pretty much everything you might need to know to get started. This is only callable in views as $this refers to the current controller object.

pestaa
Yes that works, but if I want to display the Student_Contact controller in the Student (MVC) views, how do I do that?
Roland
Generally it's discouraged to cross-call controllers. If you have some common code that multiple controller use, I'd recommend put it in models.
pestaa
I do not have much time to rewrite any code otherwise I would do it another way, what works is this$model=new Student;$this->renderPartial('student_Contact/show',array('model'=>$model));but $model=new Student_Contact;$this->renderPartial('student_Contact/show',array('model'=>$model));does not want to work
Roland
Because show view expects 'model' to be a model, not a controller. If you are short on time, why not just duplicate the required code?
pestaa
I decided to duplicate the required code, thanks again
Roland
+1  A: 

You can use views from other controllers:

$this->renderPartial('application.views.student_Contact.show',array('model'=>$model));

Hope this helps.

manta18gt
Thanks, I'll try this if I need to do this again
Roland