I want to add custom view helper in zend framework like this:
- I placed in application.ini this code:
includePaths.library = APPLICATION_PATH "/../library"
and create library directory in myproject root - create view helper TabEntry.php in library directory
class Zend_View_Helper_TabEntry extends Zend_View_Helper_Abstract {
public function TabEntry() {
}
} - create another view helper TabEntries.php in library directory
class Zend_View_Helper_TabEntries extends Zend_View_Helper_TabEntry {
public function TabEntries() {
}
} - when in my phtml use $this->TabEntries() get error
- in Bootstrap.php I add some code:
$view->addHelperPath('MyView/Helpers', "library_MyView_Helpers");
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); $viewRenderer->setView($view);
Zend framework/located in
/var/www/html/you
1)
you/application/views/helpers/<Magic is here>
2) Put this file called "Stuff.php" in above path
3) Go to you/application/views/scripts/index/index.phtml
<?= $this->stuff(); ?>
:)4) output will be the $output.
Double check the code you have in your bootstrap
Should be more like
On my side, I use:
and have that kind of class in
Julien/View/Helper/Percent.php
then calling in the view
will output
and my directory layout looks like
Add helper in zend 3
create helper class Helper.php in module/Admin/src/View/Helper/Helper.php
after that add the following code in:
module/Admin(your module name)/config/module.config.php
use Zend\ServiceManager\Factory\InvokableFactory;
call on view
According to ZF coding application structure, correct version would be:
In application.ini:
Then the helpers: (not sure why do you need another abstract class):
In the view:
Important:
call_user_func
and Linux filesystem are case sensitive.