verbb / vizy

A flexible visual editor for Craft CMS
Other
44 stars 8 forks source link

How to access the `entry` variable in a _vizy template? #285

Open jeslage opened 8 months ago

jeslage commented 8 months ago

Question

Sometimes we need to access the global entry variable in a _vizy/*.twig template. We havent found a solution for this in the documentation or existing issues. How do we access the variable? Is there a proper way to do this? Currently we fetch the entry again based on the given request uri, but this seems to be a bit inefficient.

Thank you!

Additional context

No response

engram-design commented 8 months ago

I suppose the tricky thing here is that Vizy fields aren't always on an entry, they can be attached to any element. You should be able to access the greater Twig scope with _context, but I'll see what can be done about injecting the owner element into these templates.

jeslage commented 8 months ago

Thanks for your fast reply! The _context variable was also my first thought, but I didn't find a parent element on that. That's right, the field is not always a child of an entry, but accessing the parent element would be a nice feature.