0
votes

How can I access different Widgets of FlowPart in Orchard Core Template?

I know that we can access FlowPart by the following command

{{ Model.Content.FlowPart | shape_render }}

but I need to access each widget in FlowPart section.

1
Formatting and tags.Tanveer Badar

1 Answers

1
votes

Model.Content is a zone shape and by accessing Model.Content.FlowPart you are actually accessing shape of the FlowPart that is placed on content zone and not the the actual FlowPart object

You can access FlowPart object and all widget objects using following.

Model.Content.FlowPart.FlowPart.Widgets

Here widgets in FlowPart.Widgets are not shapes so you need to build shape first with shape_build_display

{% for widget in Model.Content.FlowPart.FlowPart.Widgets %}
  {{ widget | shape_build_display: "Detail" | shape_render }}
{% endfor %}

If you directly want to work on data and not shapes then you can access JSON data using following to get JSON for any ContentItem

{{ Model.ContentItem.Content }}

and to get FlowPart JSON object you can do something like following

{{ Model.ContentItem.Content.FlowPart }}

Or to get list of widgets JSON array

{{ Model.ContentItem.Content.FlowPart.Widgets }}