nliautaud / pico-pages-list

A pages lists plugin for Pico CMS, with nested pages, pages filtering and HTML navigation.
MIT License
12 stars 8 forks source link

Unable to add filter "navigation" as extensions have already been initialized. #16

Closed Geri-Borbas closed 6 years ago

Geri-Borbas commented 6 years ago

Hi, I just added the file to plugins, now it throws this below (using pico 2).

Fatal error: Uncaught exception 'LogicException' with message 'Unable to add filter "navigation" as extensions have already been initialized.' in <PATH>/vendor/twig/twig/lib/Twig/Environment.php:1103

Stack trace:
#0 /<PATH>/plugins/PicoPagesList.php(73): Twig_Environment->addFilter(Object(Twig_SimpleFilter)) #1 [internal function]: PicoPagesList->onPageRendering(Object(Twig_Environment), Array, 'help.twig')
#2 <PATH>/vendor/picocms/pico/lib/AbstractPicoPlugin.php(117): call_user_func_array(Array, Array)
#3 <PATH>/plugins/PicoDeprecated/PicoDeprecated.php(857): AbstractPicoPlugin->handleEvent('onPageRendering', Array)
#4 <PATH>/plugins/PicoDeprecated/PicoDeprecated.php(689): PicoDeprecated->triggerEvent(1, 'onPageRendering', Array)
#5 [internal function]: PicoDeprecated->onPageR in <PATH>/vendor/twig/twig/lib/Twig/Environment.php on line 1103

Any missing dependency, or what?

nliautaud commented 6 years ago

Hi, did you use the branch pico-2.0 for Pico 2 ? I was waiting for the pico 2 release, but I'll make a pre-release to clarify.

Geri-Borbas commented 6 years ago

Thanks! Trying it now...

Geri-Borbas commented 6 years ago

It says...

Catchable fatal error: Argument 1 passed to PicoPagesList::onPageRendering() must be an instance of string, string given in <PATH>/plugins/PicoPagesList.php on line 67

...now.

Geri-Borbas commented 6 years ago

PhpStorm suggests this: screen shot 2018-02-19 at 17 35 23

Geri-Borbas commented 6 years ago

I removed string. Now it falls back to:

Fatal error: Uncaught exception 'LogicException' with message 'Unable to add filter "navigation" as extensions have already been initialized.' in <PATH>/vendor/twig/twig/lib/Twig/Environment.php:1103 Stack trace:
#0 <PATH>/plugins/PicoPagesList.php(74): Twig_Environment->addFilter(Object(Twig_SimpleFilter))
#1 [internal function]: PicoPagesList->onPageRendering('help.twig', Array)
#2 <PATH>/vendor/picocms/pico/lib/AbstractPicoPlugin.php(117): call_user_func_array(Array, Array)
#3 <PATH>/vendor/picocms/pico/lib/Pico.php(2432): AbstractPicoPlugin->handleEvent('onPageRendering', Array)
#4 <PATH>/vendor/picocms/pico/lib/Pico.php(476): Pico->triggerEvent('onPageRendering', Array)
#5 <PATH>/index.php(40): Pico->run()
#6 {main} thro in <PATH>/vendor/twig/twig/lib/Twig/Environment.php on line 1103

Should I remove other plugins? I also had PicoGAnalytics.php in plugins, but the exception is still thrown without it as well.

Geri-Borbas commented 6 years ago

Could you reproduce this issue?

nliautaud commented 6 years ago

Hi, thanks for the reports ! I'm able to reproduce this error with the beta 2, and it probably impact in the same way every one of my other plugins.
Everything works fine with the beta 1, so there is probably some breaking changes somewhere here :
https://github.com/picocms/Pico/compare/v2.0.0-beta.1...v2.0.0-beta.2

I don't know how it's supposed to be handled now, maybe some info will be provided on Pico stable release.

Note that the beta 2 mainly include a page tree which aim to cover this plugin needs, and which is recommended to use with handcrafted twig functions, so I'm not sure to push this plugin forward.

Geri-Borbas commented 6 years ago

Wow, you mean I can add navigation without plugin in pico 2? Could you give me some pointers on docs / examples / tests / whatever?

nliautaud commented 6 years ago

Actually you can already with Pico 1, Pico 2 will only provide nested data. keep in mind that you'll have to craft it yourself in Twig. I don't think there is any examples or tests, but you'll find some infos in the API documentation. The development is a bit hard to follow, but you'll find some infos here : https://github.com/picocms/Pico/issues/401#issuecomment-343751698

Geri-Borbas commented 6 years ago

Thanks, crafting twig myself somewhat kills the purpose of simplicity / ready-to-go-out-of-the-box feel of pico. I mean I could create a site from the ground up, but I really want to stay content focused this time.

So I think the plugin still has added value.

nliautaud commented 6 years ago

Fixed in Pico 2.0 concerned branches/releases. https://github.com/nliautaud/pico-pages-list/pull/10