I extended Zend_View_Helper_Catmenu to Zend_View_Helper_Abstract.
class Zend_View_Helper_Catmenu extends Zend_View_Helper_Abstract
{
public function Catmenu($cats)
{
$catMenu='';
$link = '';
foreach ($cats as $cat)
{
$link = $this->view->url(array('controller' => 'cats', 'action' =>
'index', 'cat' => $cat['cat_url']));
$catMenu .= "<li> \"$link\" $cat[cat] </li>";
}
return $catMenu;
}
}
The main reason for doing this is to use $this->_request->getQuery('cat')
from the controller and I still can't use it and instead rely on
$this->_request->getParam('cat')
Any ideas on this?
thanks
Jigal Sanders wrote:
>
> Can't you just extend the view class? Like
>
> class Zend_View_Helper_Catmenu extends Zend_View(_Helper) or something
> like
> this? ?
>
> On Fri, Nov 27, 2009 at 6:16 AM, prado <pradosh_k@hotmail.com> wrote:
>
>>
>> Hi I have got a simple view helper which is sitting inside views/helpers
>> directory that generates a list of links
>>
>> class Zend_View_Helper_Catmenu
>> {
>> public function Catmenu($cats)
>> {
>> $catMenu='';
>>
>> foreach ($cats as $cat)
>> {
>> $catMenu .= "<li> \"
>> /cats/index/cat/$cat[cat_url]\">$cat[cat] </li>";
>> }
>>
>> return $catMenu;
>> }
>>
>> }
>>
>>
>> I would like to use the url helper which is in this case "echo
>> $this->url(array('controller'=>'cats', 'action'=>'index',
>> 'cat'=>$cat[cat_url]));" for the highlighted code above. As I am not in
>> the
>> view i won't be able to access the url helper.
>>
>> Any other way to access a helper inside my custom helper, like in this
>> example
>> --
>> View this message in context:
>> http://n4.nabble.com/access-url-view-helper-from-my-custom-view-helper-tp788528p788528.html
>> Sent from the Zend MVC mailing list archive at Nabble.com.
>>
>
>
>
> --
> Met vriendelijke groet,
>
> Jigal Sanders
> A.J. Ernststraat 739
> 1082 LK Amsterdam
> Mobiel: 06-42111489
>
>
--
View this message in context: http://n4.nabble.com/access-url-view-helper-from-my-custom-view-helper-tp788528p930949.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论