Hello again :) this time an easy one.
It's possible to tell an action in a controller to use the same view another action uses? For example, when I call listing() in a controller, akelos loads listing.tpl and I'd like to tell filtering() to use the same listing.tpl instead of filtering.tpl
Thanks!
If I understand your problem you should use :
$this->renderAction('listing');
regards.
Don't worry about your english, it's just fine.
renderAction is the thing you need, really.
The name "renderAction" doesn't maybe fit well with what is does : it calls the specified template to render the current action.
At the end of your filtering() action, just add :
$this->renderAction('listing');
It will compute your filtering() and then use the listing.tpl.
It's not a redirection to another action. To redirect to listing() you would have to use :
$this->redirectToAction('listing');
Come back here if that doesn't work.
Best regards.
I'm using this code to check, I've cleaned it up a bit tho
user_controller.php
class UserController extends ApplicationController
{
var $layout = 'admin'; // I have layouts/admin.tpl with the HTML head, body, etc...
function index()
{
$this->renderAction('listing');
}
function listing()
{
$this->content_title = "Listing loaded";
}
function filtering()
{
$this->content_title = "Filtering loaded";
$this->renderAction('listing');
}
}
listing.tpl
<div>{content_title}</div>
Notice that filtering.tpl exists and is empty (just has <?php ?> inside) and index.tpl doesn't exist.
When I load /user in the browser the index action takes place and "calls" listing, so I get "Listing loaded". The same happens if I load /user/listing. But when I load /user/filtering I get 'Listing loaded' too instead the expected "Filtering loaded".
So it's obvious it's always using listing.tpl, but also running the code inside listing(). That's why I thought renderAction did some kind of action redirection :) but I'm sure it's me doing something wrong, heheh...
Regards.
Made it work using
$this->render(array('template'=>'listing'));
instead of
$this->renderAction('listing');
in filtering() function :)
see ticket #147
1 to 7 of 7