php - How Action helper communicate with view helper -


i create action helper file path

c:\xampp\htdocs\ecom\application\controllers\helpers

file name :inputdata.php

class zend_controller_action_helper_inputdata extends zend_controller_action_helper_abstract {     function inputdata()     {         return $this;     }       function fetch_db_value($var)         {         if(get_magic_quotes_gpc()==0) {             return is_array($var) ? array_map(array($this,'fetch_db_value'), $var) : nl2br(stripslashes(trim($var)));             }else {             return is_array($var) ? array_map(array($this,'fetch_db_value'), $var) : nl2br(trim($var));             }         }       } 

i calling function on controller giving output proper :

$dbdata=$this->_helper->inputdata->fetch_db_value($dbdata);  

i have view helper, path

c:\xampp\htdocs\ecom\application\views\helpers

file name : comman.php

class zend_view_helper_comman {     public function displayproducts($res){                  # res array                            foreach($res $val){                   # $val sub array of array $res                    $val=$this->_helper->inputdata->fetch_db_value($val);                    print_r($val)                 }     } } 

this function

$this->_helper->inputdata->fetch_db_value

is giving error

  1. any idea syntax how user action helper custom function in view helper custom function
  2. syntax how call function displayproducts() on controller

re: action helper:

the namespace prefix on action helper zend_. autoloader in location in zend framework library resides. in order autoloader - resource loader, in case - action helper in application/controllers/helpers, namespace prefix has appnamespace, typically application_. renaming class application_controller_helper_inputdata should trick.

re: view helper:

a similar thing applies. typically, use appnamespace prefix application_. renaming class application_view_helper_comman should make displayproducts() method accessible in view-script as:

$this->comman()->displayproducts($res) 

you mention referencing view-helper method in controller. typically not done; view-helpers referenced in view-scripts. however, if want it, can access via view object. in controller:

$this->_view->comman()->displayproducts($res) 

if view-helper going contain single displayproducts() method, can rename class application_view_helper_displayproducts , reference method in view-script using:

$this->displayproducts($res) 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -