Some other frameworks have a link helper like output_link('anchor', 'destination');
to replace the need to type <a href=""></a>
into the template. Does Zend have something similar? and do I have to declare the link in the action first before I can use it in the viewer?
views:
44answers:
3
+2
A:
I am not sure if Zend has this, but all you would need to do is create your own outputLink
in the View Helper (applications/views/helpers/
) and set it up how you want to, should be pretty trivial.
class Zend_View_Helper_OutputLink extends Zend_View_Helper_Abstract
{
public function outputLink($anchor, $description)
{
return '<a href="' . $anchor . '">' . $description . '</a>';
}
}
Just modify it how you want to. And you would call it in your view like below:
<span><?php $this->outputLink('test.html', 'Test Me!'); ?> </span>
Brad F Jacobs
2010-10-08 20:31:56
For outputting HTML tags is better to extend `Zend_View_Helper_HtmlElement` instead `Zend_View_Helper_Abstract`. It has nice methods for handling HTML attributes.
takeshin
2010-10-10 16:30:47
I will take a look into that. Thanks.
Brad F Jacobs
2010-10-11 19:25:02
+5
A:
Zend_View_Helper_Url can generate URL in view, take a look on its API doc http://framework.zend.com/apidoc/core/Zend_View/Helper/Zend_View_Helper_Url.html
ngsiolei
2010-10-08 20:49:07