CakePHPs features.
Separate the parts from the two views, that you would like to be
presented together, and put them into elements.
Taking your example below, in the view, add the usage of the two
elements, thus presenting both in the same view.
How you are going to handle to paginations in the same view is a task
for you to handle :)
Thus you have no need to import the other controller, which in my
opinion is a non-CakePHP thing!
Enjoy,
John
On Dec 4, 8:10 am, "Jorge J. Ramirez" <jramirez.sanc...@gmail.com>
wrote:
> Hi all!
>
> I'm learning cakePHP and I'm trying to combine 2 index views of 2
> different controllers, imagine that I have a controller (and model) to
> manage tasks and other to manage orders, what I need is to combine the
> 2 index views to show in a page the two tables with pagination.
>
> Tasks Title
> Table 1
>
> Activities Title
> Table 2
>
> Actually I'm importing one Controller into the other and using the
> $this->element() method now I can display the 2 views, but I'm getting
> errors, here's part of my controller code:
>
> [code]
> <?php
> App::import('Controller', 'Orders');
> class TasksController extends AppController {
>
> var $Orders;
> var $name = 'Tasks';
> var $helpers = array('Html', 'Form');
>
> function beforeFilter() {
> $this->Orders =& new OrdersController;
> $this->Orders->constructClasses();
> }
>
> function index() {
> $this->Task->recursive = 0;
> $this->set('tasks', $this->paginate());
> $this->set('orders', $this->Orders->paginate());
> }
> ?>
> [/code]
>
> in the Tasks view I'm using:
>
> <?php echo $this->element('../orders/index'); ?>
>
> And errors athttp://localhost/imagen/tasks/indexare:
>
> Notice (8): Undefined index: url [CORE\cake\libs\controller
> \controller.php, line 979]
> Warning (2): array_merge() [function.array-merge]: Argument #2 is not
> an array [CORE\cake\libs\controller\controller.php, line 979]
> Warning (2): array_keys() expects parameter 1 to be array, null given
> [CORE\cake\libs\controller\controller.php, line 1019]
> Warning (2): array_merge() [function.array-merge]: Argument #3 is not
> an array [CORE\cake\libs\controller\controller.php, line 1045]
> Warning (2): extract() expects parameter 1 to be array, null given
> [CORE\cake\libs\controller\controller.php, line 1045]
> Warning (2): Division by zero [CORE\cake\libs\controller
> \controller.php, line 1072]
>
> Thanks for your help.
>
> Regards.
>
> Jorge
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment