开发者

How can i make my own view helpers such as $this->partial or $this->render?

Like we can do $this->partial(); or $this->render() with Zend Framework. How can i make my own $this->myOwnStuff(); ?

Example:
Before:
<tr>
 <td>label</td>
 <td>value1</td>
</tr>
<tr>
 <td>label2</td>
 <td&开发者_Python百科gt;value2</td>
</tr>

After:
$this->tr(
  array(
    "label"=>"value1", "value"=> "value1"
    "label"=>"value2", "value"=> "value2"
  )
);


It's pretty easy. If you want to create a helper, just create a new helper class and plot it in /application/views/helpers. Of if you're structuring it so that you have your own library putting it in library/My_Library/View/Helper will also work.

Make sure to extend from the base helper abstract. Something along the lines of

class My_View_Helper_Stuff extends Zend_View_Helper_Abstract {
}

Here's an article that goes into greater detail about the matter : http://devzone.zend.com/article/3412

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜