First, please specify your cake version, as it generally makes a huge
difference if you're on 1.1 or 1.2. I'm going to assume you're on the
1.2 beta.
If you want EVERY method in your ChildController to render the
parent's view, it's easy-peasy
class ChildController extends SomeParentController {
function __construct() {
parent::__construct();
$this->viewPath = 'some_parent'; // Look in app/views/some_parent/
xyz.ctp
}
}
If it's only for certain actions, it gets a little trickier. You can
set $this->viewPath in the action method itself, or in beforeRender(),
based on certain conditions.
If you need to only use the parent's view if the child's view folder
doesn't contain the .ctp file, you're on your own. It's the view's
responsibility to check if the template exists, not the controller's,
so you're probably going to have to use a custom view.
Hope this helps
grigri
On Jan 21, 3:57 pm, Tomka <[EMAIL PROTECTED]> wrote:
> Hello.
>
> I wrote two controllers:
>
> ChildController extends ParentController
> and
> ParentController extends AppController
>
> If the action "foo" (which is defined in ParentController) is invoked
> on the ParentController cake displays the view "parent/foo".
> So far so good.
> If the action "foo" is invoked on ChildController cake acts as I
> suggested: the action from the parent class is invoked. But cake tries
> to display the view "child/view".
> How can I tell cake to display "parent/foo"?
> I tried the render($action, $layout, $file) function but I do not
> understand the parameters: I could get my view with $action = "parent/
> view" nor with anything in $file.
>
> Can anyone help me.
>
> Thanks in advance,
>
> Thomas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---