diff --git a/PicoPagesList.php b/PicoPagesList.php index 2457aec..eed9c5d 100644 --- a/PicoPagesList.php +++ b/PicoPagesList.php @@ -70,19 +70,13 @@ protected function onCurrentPageDiscovered( /** * Register `$this` in the Twig `{{ PagesList }}` variable. * - * Triggered before Pico renders the page * * @see Pico::getTwig() - * @see DummyPlugin::onPageRendered() - * @param string &$templateName file name of the template - * @param array &$twigVariables template variables + * @param Twig_Environment &$twig Twig instance * @return void */ - public function onPageRendering(string &$templateName, array &$twigVariables) + public function onTwigRegistered(Twig_Environment &$twig) { - $twig = $this->getPico()->getTwig(); - $twigVariables['nested_pages'] = $this->items; - $twig->addFilter(new Twig_SimpleFilter('navigation', function($pages) { return $this->output($pages); })); @@ -96,6 +90,23 @@ public function onPageRendering(string &$templateName, array &$twigVariables) }, array('is_variadic' => true))); } + /** + * Register `$this` in the Twig `{{ PagesList }}` variable. + * + * Triggered before Pico renders the page + * + * @see Pico::getTwig() + * @see DummyPlugin::onPageRendered() + * @param string &$templateName file name of the template + * @param array &$twigVariables template variables + * @return void + */ + + public function onPageRendering(string &$templateName, array &$twigVariables) + { + $twigVariables['nested_pages'] = $this->items; + } + /** * Create the nested pages array according to the pages paths. *