I usually do something like this

$data = $this->Page->read();
// do stuff with data array

$this->set('data',$data);



On 4/4/06, mikis <[EMAIL PROTECTED]> wrote:
>
> Hello, I'd like to switch layouts "on the fly", based on record in the
> database. To explain:
>
> There are two simple classes, Pages and Categories, where each Page
> belongs to Category (and Category $hasMany Pages). Each Category has
> different layout . I've managed to call it from Pages controller using
> this:
>
> <?php
> class PagesController extends AppController {
>   var $name = 'Pages';
>
>   function show ( $id )   {
>     $this->set('data', $this->Page->Read());
>     $this->layout = $this->_viewVars['data']['Category']['template'];
>    // where category.template = template1 | template2 | template3...
> and in /views/layouts there are files template1.thtml, template2.thtml,
> template3.thtml...
>   }
> }
> ?>
>
> But there must be a more elegant way to access data returned by Read()
> or FindAll() methods?
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to