Hola
masterpuppet,
El module donde estoy probando está así.
No tiene nada mas.
Código:
/module-dev
/Reference
/Navigation
/config
module.comfig.php
/src
Navigation
/Controller
IndexController.php
/View
/Helper
NavigationMenu.php
/view
/navigation
/index
index.phtml
Module.php
autoload_classmap.php
autoload_function.php
autoload_register.php
module.config.php
Código PHP:
return array(
'navigation' => array(
// The DefaultNavigationFactory we configured in (1) uses 'default' as the sitemap key
'default' => array(
// And finally, here is where we define our page hierarchy
array(
'label' => 'Products',
'module' => 'products',
'controller' => 'index',
'action' => 'index',
'pages' => array(
array(
'label' => 'Server',
'module' => 'navigation',
'controller' => 'index',
'action' => 'index',
'pages' => array(
array(
'label' => 'Index',
'module' => 'index',
'controller' => 'index',
'action' => 'index'
),
array(
'label' => 'Editions',
'module' => 'products',
'controller' => 'server',
'action' => 'editions'
),
array(
'label' => 'System Requirements',
'module' => 'navigation',
'controller' => 'index',
'action' => 'index'
)
)
),
)
),
),
),
'controllers' => array(
'invokables' => array(
'Navigation\Controller\IndexController' => 'Navigation\Controller\IndexController',
),
),
'router' => array(
'routes' => array(
'navigation' => array(
'type' => 'literal',
'options' => array(
'route' => '/navigation',
'defaults' => array(
'controller' => 'Navigation\Controller\IndexController',
'action' => 'index',
),
),
),
),
),
'view_helpers' => array(
'invokables' => array(
'navigationMenu' => 'Navigation\View\Helper\NavigationMenu',
),
),
'service_manager' => array(
'factories' => array(
'Navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory'
),
),
'view_manager' => array(
'template_path_stack' => array(
__DIR__ . '/../view'
),
),
);
NavigationMenu.php
Código PHP:
namespace NavigationViewHelper;
use ZendViewHelperAbstractHelper;
use ZendNavigationPageAbstractPage;
class NavigationMenu extends AbstractHelper
{
public function htmlify(AbstractPage $page, $escapeLabel = true)
{
var_dump($page); //solo para comprobar salida
}
public function renderMenu($container = null, array $options = array())
{
var_dump($container); //solo para comprobar salida
}
}
index.phtml
Código PHP:
<?php
$label = $this->navigation('Navigation')->findOneByLabel('Server');
$options = array(
'ulClass' => 'nav nav-list',
);
?>
<?php echo $this->navigation('Navigation')
->findHelper('navigationMenu')
->menu()
->renderMenu($label, $options); ?>
Module.php
Código PHP:
namespace ReferenceNavigation;
class Module
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getViewHelperConfig()
{
return array(
'invokables' => array(
'navigationMenu' => 'Navigation\View\Helper\NavigationMenu',
),
);
}
}
Seguro que está todo
Gracias. Un saludo,