Is it possible to use a template Controller within a Template controller?
I mean, I've created a simple Template Controller(let's call it A controller), as the doc shows. After, I followed a tutorial about scaffolding. After this second tutorial I have another
template controller (B controller, let's say) that allows me to create/edit/delete/show the content of a DB table called 'product'. After this, I tried to combine these two Template
Controller in order to have the footer and header (included in my first template controller) wrapping the 'product' managing. Aaaand... I just got stuck here.
I tried by making the B controller extending my A controller. This way I'd have the footer and header, but I'd lose half of the content displayed by B controller...
I'm sure this is something that I might achieve using fuelphp, But still I don't know how.
nesting both templates, but I'm not sure about how to do it. My best try, by having a Controller_B extending Controller_A extending Controller_Template was:
But this way, half of the second template is lost. I'd like to know wich is the right way to do what I want (if it's possible). Also, I'll take your advice and have a look at Theme class.
You need a base controller (your controller A) which sets up the page template, and fills in all static sections of the template, in the before() method of the base controller.
Your app controller (controller B) extends your base controller, and needs to fill in the body section of your template in the action method being called.
The problem you have is that your app controller now uses the standard generated code, which assumes it has full control over the template. It needs to fill in only the body section of the template. A standard scaffold controller will assign the body view to the 'content' property of the template. You will have to make sure this is the body section of the template.
If you're saying the output is not correct, then you've setup your base controllers before method wrong, or your template layout is not correct.
You will have exactly the same issue with Theme, so switching to that is not going to solve your coding problem.
Perhaps you should post the code of Controller A, B and your template (on http://snipr.it) so I can have a look at it and tell you where you've gone wrong?
Apart from your coding style, I think it looks ok. :-)
At first glance, the only remark I have is about your after() method. Once you have called the parent::after(), your page template is wrapped into a response object and returned. So you should assign the content to the template before you call the parent.
I this case it will work because it's an object and is passed by reference, so later modifications will work, but you should not rely on that.