eZ Platform Discussions

How to get value from controller in a template


#1

Hi all,

I have content type (point of interest) with a relation list to one or more municipalities.

The content type municipality has a boolean value for “Show filters on maps”.

When viewing a Point of interest, I want to check with all related municipalities if the boolean is true or false.

AFAIK the {{render(controller())}} is for rendering. What I need i fetching the objects or even the boolean values (e.g. in an array).


#2

Something like this?

{% for municipality in point_of_interest.filterRelation([‘municipality’]) %}
{% if municipality.fields.show_filters_on_maps.value %}
// do something
{% endif %}
{% endfor %}


#3

Btw. you need Site API version 2.3 for this: https://github.com/netgen/ezplatform-site-api/releases/tag/2.3.0
We just released it :slight_smile:


#4

Thanks!

The Site API is looking better by the day, and has some things that should be included in the basic configuration IMO. I will consider to make widespread use of it.

For now I went for the “boring” solution. Isolated the code in a include template with a controller.