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

    Hi everybody!

    This time I'm asking about application helper. Is there such a helper in Akelos? How to use it?

    Thanks for your help and time =)

    -jyrki

    • CommentAuthorsalavert
     

    There is no such helper in the Akelos PHP Framework, there are two types of helpers, view helpers located at framework/lib/AkActionView/helpers and custom helpers mixed into the views based on the controller name.

    There is a way to add a custom helper to your app, this helpers should be located in the app/helpers directory, by example If you create a helper called layout_helper.php and you wish that your app include this helper this is the way to do it

    class ApplicationController extends AkActionController { var $app_helpers = 'layout'; }

    • CommentAuthoriJyrki
     

    Thank you, salavert! You've saved my day again :D

    -jyrki

    • CommentAuthoriJyrki
     

    Another related question. How to add more app_helpers in another controller?

    -jyrki

    • CommentAuthorsalavert
     

    If you want to load layout_helper and my_cool_functionality_helper you just need to tell akelos

    class ApplicationController extends AkActionController
    {
        var $app_helpers = 'layout, my_cool_functionality';
    }
    

    cool eh!!

    • CommentAuthoriJyrki
     

    Thank you again, salavert! And sorry for my newbie-ish questions..

    Is there any way to extend the variable app_heplers in another controller than ApplicationController? Like

    class QuestbookController extends AkActionController
    {
        var $app_helpers = /*app_helpers from application_controller + app_helpers from this controller*/
    }
    

    -jyrki

    • CommentAuthorsalavert
     

    Not using an Akelos way "yet", but some old school PHP could help by doing this in your application_controller.php:

    define('MY_APP_HELPERS', 'layout');
    

    And then just concatenate them like:

    class QuestbookController extends AkActionController
    {
        var $app_helpers = MY_APP_HELPERS.', my_cool_functionality';
    }
    

    Not perfect, but if you find a bright way to integrate this into the Akelos core, it would be nice to submit a patch so we can improve it.

    In case you wanna know, the file where this takes place is located at lib/AkActionController.php

    • CommentAuthoriJyrki
     

    Another workaround:

    class QuestbookController extends AkActionController
    {
        function __construct()
        {
            $app_helpers = $this->app_helpers.', captcha';
        }
    }
    

    I think this is a bit better than defining the MY_APP_HELPERS constant...

    -jyrki