Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should rather use <a href="http://framework.zend.com/manual/1.11/en/zend.controller.actionhelpers.html" rel="nofollow"><strong>Action Helpers</strong></a>, not plugins.</p> <p>That way, you could do for example <code>$this-&gt;_helper-&gt;getLang()</code> to get the lang in your action (with <code>GetLang</code> being your Action Helper), rather than use a class attribute.</p> <p>Plugins are useful to control the routing of the request (for example to add ACL filtering). This is not what you want to do here.</p> <p>Example code for your helper:</p> <pre><code>class MyModule_Controller_Helper_GetLang extends Zend_Controller_Action_Helper_Abstract { /** * direct() is the default method called * when you use $this-&gt;_helper-&gt;getLang() */ public function direct() { $lang = /*get you lang here*/; return $lang; } } </code></pre> <p>Tutorials:</p> <ul> <li><a href="http://www.phpbuilder.com/columns/zend-action-helpers/Jason_Gilmore091410.php3" rel="nofollow">http://www.phpbuilder.com/columns/zend-action-helpers/Jason_Gilmore091410.php3</a></li> <li><a href="http://tournasdimitrios1.wordpress.com/2011/04/24/zend-framework-a-basic-example-of-zend-controller-action-helper/" rel="nofollow">http://tournasdimitrios1.wordpress.com/2011/04/24/zend-framework-a-basic-example-of-zend-controller-action-helper/</a></li> </ul> <p>I recommend to put your helpers in /application/controllers/helpers. See the official recommendation for <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend+Framework+Default+Project+Structure+-+Wil+Sinclair#ZendFrameworkDefaultProjectStructure-WilSinclair-9.ClassSkeletons" rel="nofollow">directory layout</a>. They say :</p> <blockquote> <p><strong>controllers/helpers/</strong> - These directories will contain action helpers. Action helpers will be namespaced either as "Controller_Helper_" for the default module or "Controller_Helper" in other modules. </p> </blockquote> <p>Update:<br> I've used a base controller before knowing about action helpers, that does the job, but lets say helpers are there exactly for that. This is a concept created exactly for what you want to do, with some advantages (like lazy loading, so that the helper is loaded only when you use it). Imagine in a week you need to add another variable, but needed only in some pages, not all. With a base controller, those variables would be loaded every time. You should rather learn how to do it right (with helpers), so that you can use it fully later. That will keep you code clean and organized. <strong>A controller is just a controller, a helper is just a helper</strong>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload