1

According to the docs, if I call a hook from within my template:

The $context argument will be the current Twig context array, which you’re free to manipulate.

So I have a loop in my template where summary is a model I've created:

{% for summary in bookings %}
    {% hook 'microsGetBooking' %}
{% endfor %}

If I understand correctly, the $context variable passed to my hook should be a reference to that summary object. However it always appears to be an EntryModel (in this case the template I'm calling this on has a URL that matches an entry in the CMS).

What am I missing here?

1

If I understand correctly, the $context variable passed to my hook should be a reference to that summary object.

Nope... $context is a reference to the entire Twig rendering context of which your bookings objects will be a part of.

You can use xDebug or var_dump to see where your bookings objects are stored and loop though them as necessary from PHP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.