如何利用ViewHelper类中的现有部分?
<?php
namespace Navigation;
use Zend\View\Helper\Navigation\AbstractHelper;
class MenuViewHelper extends AbstractHelper
{
public function render($container = null)
{
// need something like $this->partial() here
return $this->getPartial("navigation/topmenu"); // ???
}
}
答案 0 :(得分:1)
您可以使用getView
AbstractHelper
(又名。HelperInterface
)的partial
方法,然后调用class MenuViewHelper extends AbstractHelper
{
public function __invoke()
{
return $this->getView()->partial('navigation/topmenu');
}
}
方法。这是一个例子:
string