0

I have some general functions like printObject, mysql2date and other that i wan't to use it site wide. Where should i place the functions.php file (or any other filename) in the ZF drectory and how should i call the functions?

I tried now to set them up in library/helpers/action/Utils.php but than i have to call them like this:

$this->_helper->utils->deg($page, true)

And the main problem is that this works only in the controller and not in the .phtml files.

5
  • 1
    We're just using some kind of "Util" Class, located in /library/App/Utils.php with static methods. Commented Oct 1, 2013 at 6:02
  • and how do you call the methods? Commented Oct 1, 2013 at 6:08
  • 1
    We declare them as static "public static function convert();" -> App_Utils::convert(); Commented Oct 1, 2013 at 6:15
  • So i created the following folder structure: library/Plugins/Utils.php. After this in the application Bootstrap.php I called something like this: $frontController->registerPlugin(new Plugins_Utils()) and than in the index.phtml file I call it like this Plugins_Utils::mysql2date('d/m/Y', $page->date_added). So it works, but is it also the right method? Commented Oct 1, 2013 at 6:30
  • Use ActionHelpers for Controllers, ViewHelpers for Views. Or try this approach: stackoverflow.com/questions/8299396/… Commented Oct 1, 2013 at 6:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.