Created
March 17, 2013 01:40
-
-
Save Freeaqingme/5179181 to your computer and use it in GitHub Desktop.
Generate sitemap with #ZF2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sm = $e->getApplication()->getServiceManager(); | |
$routes = $sm->get('config')['router']['routes']; | |
echo '<ul>' . $this->parseRoutes($routes) . '</ul>'; | |
protected function parseRoutes($routes, $names = array(), $url = array()) | |
{ | |
echo '<ul>'; | |
foreach ($routes as $name => $route) { | |
echo '<li>'; | |
if (isset($route['options'])) { | |
echo '<a href="' . implode($url). $route['options']['route'] . '">' . $name . '</a>'; | |
} | |
if (isset($route['child_routes'])) { | |
echo $this->parseRoutes($route['child_routes'], $names + array($name), array_merge($url, array($route['options']['route']))); | |
} | |
echo '</li>'; | |
} | |
echo '</ul>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From my understanding I wrote following content in my phtml file.
and I wrote the below content in my controller
But it is giving error undefined variable e for this line $sm = $e->getApplication()->getServiceManager(); .