MB Views and Timber Conflict
- This topic has 4 replies, 2 voices, and was last updated 4 years, 1 month ago by
Matt V.
-
AuthorPosts
-
October 31, 2021 at 3:33 AM #31658
Matt V
ParticipantI'm using MB Views to create a header for my Post pages. And I've got some additional Twig-based functionality on the site that requires Timber.
Everything seems to work fine until I add a date field with a filter to MB Views. Then my front-end templates throw an error.
The specific error is:
Fatal error: Uncaught TypeError: Argument 1 passed to twig_date_format_filter() must be an instance of Twig\Environment, instance of MetaBox\Dependencies\Twig\Environment given, called in /Users/matt/Local Sites/center-blueprint/app/public/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-views/dependencies/Twig/Environment.php(358) : eval()'d code on line 37 and defined in /Users/matt/Local Sites/center-blueprint/app/public/wp-content/plugins/timber-library/vendor/twig/twig/src/Extension/CoreExtension.php on line 41I've posted the full call trace here.
I've removed all other plugins besides Meta Box and Timber and the problem persists. I've reduced my MB Views template to just the date field:
{{ post.date | date( 'F j, Y' ) }}and it is clearly the date field that triggers it.I'm using MB AIO 1.15.2 and Timber 1.19.1, which I think are the latest versions of each.
I don't know if my issue is related to this one, but it sounds like it could be.
November 1, 2021 at 11:31 AM #31669Long Nguyen
ModeratorHi,
The plugin Timber uses the Twig version 1.42.5 while MB Views uses the newer version 3.2.1 so I think it could be a conflict between the two versions.
You can try to deactivate the plugin Timber to re-check the issue.
November 4, 2021 at 6:42 AM #31723Matt V
ParticipantThanks for the reply, Long. It makes sense to me that the different versions might conflict in unexpected ways.
Deactivating Timber does fix the issue, but then I lose the other functionality.
Is there a way to scope/namespace/prefix the MB Twig usage?
I found an issue on the Timber repo showing how another plugin handled a similar conflict. I don't know enough about MB development to know whether that would be appropriate or even possible.
November 4, 2021 at 12:24 PM #31731Long Nguyen
ModeratorHi,
FYI, the MB Views plugin runs Twig functions/classes under the namespace
MBViews. Please contact Timber plugin support to ask for help with this issue.November 4, 2021 at 12:28 PM #31732Matt V
ParticipantThanks, Long. That's helpful to know. I'll ask the Timber folks.
-
AuthorPosts
- You must be logged in to reply to this topic.