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

    I have founded that I'm unable to use a variable defined in the ApplicationController class inside a template when using renderAction() inside an action, but it's available when using the default action's template.

    Sample code: when calling /port/listing the template shows correctly $users_online (5) and $another_var (1), if I call /port/inputs shows $another_var (2) value but it drops me a Notice : Undefined variable for $users_online.

    Any clue? Thanks in advance.

    Btw, sorry about my "usually long" posts but it's the only way to explain myself when the english level it's not enough ^_^.

    application_controller.php

    class ApplicationController extends AkActionController {
        var $users_online = 5;
        //......
    }
    

    port_controller.php

    class PortController extends ApplicationController {
        var $layout = 'admin';
        function listing() {
             $this->another_var = "1";
        }
        function inputs() {
            $this->another_var = "2";
            $this->renderAction('listing');
        }
    }
    

    listing.tpl

    <div><?= $users_online ?></div>
    <div><?= $another_var ?></div>
    
    • CommentAuthorinsanet
     
    mmm interesting. the code looks ok. nothing wrong. i never needed to do something like that. so i never noticed this. maybe a bug.
    • CommentAuthorasejua
     

    Yuk! I've founded that I made a mistake that probably changes it all, the code I posted above works... (blush xD)

    The problem comes when, with the same scenario, the variables are defined for ApplicationController inside an afterFilter-called function.

    So application_controller.php would be:

    class ApplicationController extends AkActionController {
    //......
        function _construct() {
            $this->afterFilter('_getOnlineUsers');
        }
    
        function _getOnlineUsers() {
            $this->users_online = 5;
        }
    }
    

    The rest is exactly the same, and the behaviour is what I wrote before: When calling 'listing' action shows up $users_online, if I call 'inputs' action, it doesn't.