Here is my helper class
class Zend_View_Helper_CommonArea extends Zend_View_Helper_Abstract {
public function commonArea()
{
?>
<div class="clear"></div>
<div id="quick_search">
<div class="search">
<strong>QUICK SEARCH </strong>
<input type="text" name="keyword" id="keyword" value="Enter keywords" class="form" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" />
<select name="select" id="select" class="selectstyled">
<option>Prefered Location</option>
<option>Prefered Location</option>
<option>Prefered Location</option>
<option>Prefered Location</option>
<option>Prefered Location</option>
</select>
</div>
<div class="bt_box">
<input name="find" type="submit" class="find" id="search" value="Find Jobs" />
</div>
<div class="resume"><a href="jobseeker.html"><img src="images/resume.jpg" alt="" /></a></div>
</div>
<?php
}
}
and My question is , I needed to add a new function to this class. I have tried by adding new function like
public function addBox()
{
?>
<div id="add_right_box"style="height:500px;"><h3 class="add_h2">Width 210px</h3></div>
<?php
}
to the above class, but I am getting eror something like
Plugin by name ‘AddBox’ was not found in the registry;
Here I need to know Can I add more functions to the helper class , if yes how is this possible.
First, you should return all output, not echo it directly.
From the Zend_View_Helper docs:
When you call
$this->commonArea()from the view, it will load the ‘CommonArea’ class, and then call the matching method. So a call to$this->addBox()will look for the ‘AddBox’ class – it won’t know that you expect it to be part of the ‘CommonArea’ plugin.If you want to call multiple methods from the same plugin, have the matching method return an instance of the plugin:
Then call the methods like this:
You could look at the navigation helper or the placeholder helper to see this pattern.