From EKiniWiki
[edit] A chat with ralphschindler: Zend Framework Action Helpers
[10:41am] ralphschindler: View Helpers or Action Helpers?
[10:42am] sinusss: there are two kinds of Helpers?
[10:42am] sinusss: views/helpers
[10:42am] ralphschindler: yes, generally speaking, you will find yourself writing view helpers
[10:42am] ralphschindler: i guess it depends on what you are trying to do
[10:42am] ralphschindler: generally speaking, its best to utilize view helpers from within views
[10:43am] ralphschindler: unless you can make a good case for using them from the action controller
[10:43am] sinusss: sometimes, i find the need to have a method that i used across Controllers though
[10:43am] ralphschindler: thats the purpose behind action helpers
[10:44am] ralphschindler: i would have a look in the manual under action helpers, how to register them and such
[10:44am] sinusss: how would you do write an action helper? (where do u put the file, etc)
[10:44am] ralphschindler: there are some built in action helpers: ViewRenderer, FlashMessenger, etc.
[10:44am] ralphschindler: currently, the best place to put them is as a class file in your library
[10:44am] ralphschindler: so
[10:44am] ralphschindler: you have Zend_* classes
[10:44am] ralphschindler: you might have Sinusss_Controller_Action_Helper_MyHelper
[10:45am] sinusss: that class goes to what directory and file?
[10:46am] ralphschindler: if your ZF library is in library/Zend/*
[10:46am] ralphschindler: then your classes would be library/Sinusss/Controller/Action/Helper/MyHelper.php
[10:48am] sinusss: so my class name inside MyHelper.php would be Sinusss_Controller_Action_Helper_MyHelper() ?
[10:48am] ralphschindler: yes
[10:49am] sinusss: and how would i call the methods inside MyHelper in one of my controllers/actions?
[10:49am] sinusss: oops
[10:50am] sinusss: lets say i have myTestAction() inside the Sinusss Helper
[10:50am] ralphschindler: after its registered, $this->getHelper('MyHelper')->myMethod()
[10:50am] sinusss: how would i call that in my /index/anotherTestAction
[10:50am] ralphschindler: you wouldnt put actions in your helpers per-se
[10:50am] ralphschindler: check out the existing action helpers to get a feel for what purpose they serve
[10:51am] sinusss: registering would occur in the bootsrap file?
[10:51am] ralphschindler: yes
[10:52am] ralphschindler: if you have more than one, you would regsiter the path to them, otherwise you can register the helper object directly
[10:52am] fromvega left the chat room.
[10:53am] sinusss: im going to do some reading on this
[10:53am] ralphschindler: yeah, have a look, ill be back online tomorrow if you have other questions
[10:53am] sinusss: for the view helpers...
[10:54am] sinusss: i put them in /view/helper/MyHelper.php ?
[10:54am] ralphschindler: yes
[10:54am] sinusss: a sameple classname would be something like what?
[10:54am] ralphschindler: depending on the module you are in
[10:55am] ralphschindler: Blog_View_Helper_MyHelper
[10:55am] ralphschindler: if you are in the default module, i think it would be Zend_View_Helper_MyHelper
[10:56am] sinusss: ah ok... im gonna do some reading and save this chat for reference...