Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorasejua
     

    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!

    • CommentAuthormerindol
     

    If I understand your problem you should use : $this->renderAction('listing');

    regards.

    • CommentAuthorasejua
     
    Hello and thanks for your answer merindol.

    renderAction doesn't do what I'm trying to, it calls another action inside the controller (at least that's what I think it does ^^) although after looking into AkActionController code, probably the solution is close to that.

    I'll try to explain a bit better (sorry, my english it's a bit short sometimes *^^*)
    I have two actions in a controller: listing() and filtering(), each one collects some (different) data but the code in both listing.tpl and filtering.tpl are the same.
    I'm just curious to know if there's a way to define in filtering() that it must use listing.tpl instead the one it uses by default (filtering.tpl)

    Thanks again.
    • CommentAuthormerindol
     

    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.

    • CommentAuthorasejua
     

    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.

    • CommentAuthorasejua
     

    Made it work using

    $this->render(array('template'=>'listing'));
    

    instead of

    $this->renderAction('listing');
    

    in filtering() function :)

    • CommentAuthorKaste
     

    see ticket #147