views:

41

answers:

2
+1  A: 

According to ZF coding application structure, correct version would be:

In application.ini:

resources.view.helperPath.Your_View_Helper = "Your/View/Helper"

Then the helpers: (not sure why do you need another abstract class):

// library/Your/View/Helper/TabEntry/Abstract.php

class Your_View_Helper_TabEntry_Abstract extends Zend_View_Helper_Abstract {
    public function tabEntry($param1, $param2) {} // note the lower case here
}

// library/Your/View/Helper/TabEntries.php

class Your_View_Helper_TabEntries extends Your_View_Helper_TabEntry_Abstract {
    public function tabEntries($param1, $param2) {...} // note the lower case
}

In the view:

$this->tabEntries();

Important: call_user_func and Linux filesystem are case sensitive.

takeshin
thanks for your replay
Behrang
By doing this I get this error: Fatal error: Class 'MyView_Helpers_TabEntry' not found in D:\Program Files\Zend\Apache2\htdocs\tab_cms\library\MyView\Helpers\TabEntries.php on line 3
Behrang
@Behrang Double check your file names and ensure you are following PEAR naming conventions.
takeshin
dear takeshin file names are correct, I'm really confused I want to use only one class in another OOP !!!
Behrang
A: 

Double check the code you have in your bootstrap

in Bootstrap.php I add some code:

$view->addHelperPath('MyView/Helpers', "library_MyView_Helpers");
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);

Should be more like

$view->addHelperPath('My/View/Helpers', "My_View_Helpers");
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);

On my side, I use:

// Add path to project view helpers
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->initView();
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view
    ->addHelperPath('Julien/View/Helper', 'Julien_View_Helper')
    ;

and have that kind of class in Julien/View/Helper/Percent.php

<?php
class Julien_View_Helper_Percent extends Zend_View_Helper_Abstract {

    public function percent ( $percentage ) {
        return $percentage * 100 . '%';
    }
}

then calling in the view

<?= $this->percent(0.255) ?>

will output

25.5%

and my directory layout looks like

project/
    lib/
        Julien/
            View/
                Helper/
                     Percent.php
        Zend/
    modules/
public/
   .htaccess 
   index.php
Julien