>> Is it possible to tell a controller to use multiple views?

I believe the example shown in the online manual for requestAction in
the Controllers chapter is what you're looking for
(http://manual.cakephp.org/chapter/controllers).

In this example, a function named "showUserProducts" is added to the
controller that uses "requestAction" to get the rendered view from
another model. This rendered view gets "set" to a variable for the view
to echo as needed.  This allows you to re-use a rendered view without
duplicating the code for it in another view.

You may also wish to create a new MVC that only aggregates views from
other models.  Here's an example that creates a "workspace" view that
consists of rendered views from two other models:

MODEL (app\models\workspace.php):
<?php

class Workspace extends AppModel
{
    var $name = 'Workspace';
        var $useTable = false;
}
?>

VIEW (app\views\workspaces\index.thtml):

<h2>Workspace Home - View Users and Posts</h2>

<?php

        echo $usersTable . "<br style='clear:both' />" . $postsTable;
?>

CONTROLLER (app\controllers\workspaces_controller.php):
<?php
class WorkspacesController extends AppController
{
        var $name = 'Workspaces';
        var $helpers = array('Html', 'Form');

    function index()
    {
        $this->set('usersTable', $this->requestAction('/users/index',
array('return')));
        $this->set('postsTable', $this->requestAction('/posts/index',
array('return')));

        // Now, we can echo out $usersTable and $postsTable in this
action's view to
        // see the rendered view.
    }
}?>


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to