I'm currently creating a project management system with the Zend Framework 1.12 and I got a problem with the Zend_Navigation::Sitemap()
method.
I have a controller named SitemapController
with indexAction()
inside it who disable the layout. Then, my /views/scripts/sitemap/index.phtml
script render the sitemap.
Problem, is that:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"/>
It's all I get in the /sitemap
URI. Even if my navigation.xml
is filled.
Here's all my code:
index.phtml
<?php
$this->navigation()->sitemap()->setFormatOutput(true)
->setUseSchemaValidation(false)
->setUseXmlDeclaration(true)
->setUseSitemapValidators(true);
echo $this->navigation()->sitemap()->render($this->navigation);
?>
SitemapController.php
<?php
class SitemapController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$this->view->layout()->disableLayout();
}
}
Bootstrap.php
/**
* @return Zend_Navigation
*/
protected function _initNavigation()
{
$view = $this->bootstrap('layout')->getResource('layout')->getView();
$config = new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml', 'nav');
$navigation = new Zend_Navigation($config);
$view->navigation($navigation);
}
navigation.xml
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<home>
<label>Tableau de Bord</label>
<controller>index</controller>
<action>index</action>
</home>
<project>
<label>Projets</label>
<controller>project</controller>
<action>index</action>
</project>
<tasks>
<label>Tâches</label>
<controller>tasks</controller>
<action>index</action>
</tasks>
<messages>
<label>Messages</label>
<controller>messages</controller>
<action>index</action>
</messages>
</nav>
</configdata>
Can someone tell me why it doesn't render the sitemap as it supposed to?