diff --git a/config/app/prepends/ibexa/content_view.yaml b/config/app/prepends/ibexa/content_view.yaml index 188388baa..b8865020b 100644 --- a/config/app/prepends/ibexa/content_view.yaml +++ b/config/app/prepends/ibexa/content_view.yaml @@ -100,6 +100,26 @@ system: match_all: template: "@ibexadesign/content/views/link_embed.html.twig" match: ~ + download_inline: + common: + template: "@ibexadesign/content/views/download_inline/common.html.twig" + match: + Identifier\ContentType: + - ng_video + - file + match_all: + template: "@ibexadesign/content/views/download_inline.html.twig" + match: ~ + download_link: + common: + template: "@ibexadesign/content/views/download_link/common.html.twig" + match: + Identifier\ContentType: + - ng_video + - file + match_all: + template: "@ibexadesign/content/views/download_link.html.twig" + match: ~ modal: form_common: template: "@ibexadesign/content/views/modal/form_common.html.twig" diff --git a/templates/themes/app/content/parts/content_fields.html.twig b/templates/themes/app/content/parts/content_fields.html.twig index 5aaccd650..e8a4557ba 100644 --- a/templates/themes/app/content/parts/content_fields.html.twig +++ b/templates/themes/app/content/parts/content_fields.html.twig @@ -35,6 +35,32 @@ } }) }} + {% elseif field.value.isTargetDownloadLink %} + {{ ng_view_content_embedded( + 'download_link', + { + 'contentId': field.value.reference, + 'params': { + 'label': label, + 'suffix': suffix, + 'refererLocationId': app.request.attributes.get('locationId'), + 'css_class': css_class + } + }) + }} + {% elseif field.value.isTargetDownloadInline %} + {{ ng_view_content_embedded( + 'download_inline', + { + 'contentId': field.value.reference, + 'params': { + 'label': label, + 'suffix': suffix, + 'refererLocationId': app.request.attributes.get('locationId'), + 'css_class': css_class + } + }) + }} {% else %} {% if ng_enhancedlink_has_location(field.value.reference) %} {% set href = path('ibexa.url.alias', { 'contentId': field.value.reference }) ~ suffix %} diff --git a/templates/themes/app/content/views/download_inline.html.twig b/templates/themes/app/content/views/download_inline.html.twig new file mode 100644 index 000000000..af0b3dd33 --- /dev/null +++ b/templates/themes/app/content/views/download_inline.html.twig @@ -0,0 +1,21 @@ +{# content \Netgen\IbexaSiteApi\API\Values\Content #} +{# location \Netgen\IbexaSiteApi\API\Values\Location #} + +{% set ezbinaryfile_field = null %} +{% for field in content.fields %} + {% if field.fieldTypeIdentifier == 'ezbinaryfile' %} + {% set ezbinaryfile_field = field %} + {% set break = true %} + {% endif %} + {% if break is defined %} + {% set break = loop.last %} + {% endif %} +{% endfor %} + +{% if location is defined and ezbinaryfile_field is not null %} + + {{ content.name }} + +{% else %} +

{{ content.name }}

+{% endif %} diff --git a/templates/themes/app/content/views/download_inline/common.html.twig b/templates/themes/app/content/views/download_inline/common.html.twig new file mode 100644 index 000000000..af0b3dd33 --- /dev/null +++ b/templates/themes/app/content/views/download_inline/common.html.twig @@ -0,0 +1,21 @@ +{# content \Netgen\IbexaSiteApi\API\Values\Content #} +{# location \Netgen\IbexaSiteApi\API\Values\Location #} + +{% set ezbinaryfile_field = null %} +{% for field in content.fields %} + {% if field.fieldTypeIdentifier == 'ezbinaryfile' %} + {% set ezbinaryfile_field = field %} + {% set break = true %} + {% endif %} + {% if break is defined %} + {% set break = loop.last %} + {% endif %} +{% endfor %} + +{% if location is defined and ezbinaryfile_field is not null %} + + {{ content.name }} + +{% else %} +

{{ content.name }}

+{% endif %} diff --git a/templates/themes/app/content/views/download_link.html.twig b/templates/themes/app/content/views/download_link.html.twig new file mode 100644 index 000000000..cbc9f958e --- /dev/null +++ b/templates/themes/app/content/views/download_link.html.twig @@ -0,0 +1,21 @@ +{# content \Netgen\IbexaSiteApi\API\Values\Content #} +{# location \Netgen\IbexaSiteApi\API\Values\Location #} + +{% set ezbinaryfile_field = null %} +{% for field in content.fields %} + {% if field.fieldTypeIdentifier == 'ezbinaryfile' %} + {% set ezbinaryfile_field = field %} + {% set break = true %} + {% endif %} + {% if break is defined %} + {% set break = loop.last %} + {% endif %} +{% endfor %} + +{% if location is defined and ezbinaryfile_field is not null %} + + {{ content.name }} + +{% else %} +

{{ content.name }}

+{% endif %} diff --git a/templates/themes/app/content/views/download_link/common.html.twig b/templates/themes/app/content/views/download_link/common.html.twig new file mode 100644 index 000000000..cbc9f958e --- /dev/null +++ b/templates/themes/app/content/views/download_link/common.html.twig @@ -0,0 +1,21 @@ +{# content \Netgen\IbexaSiteApi\API\Values\Content #} +{# location \Netgen\IbexaSiteApi\API\Values\Location #} + +{% set ezbinaryfile_field = null %} +{% for field in content.fields %} + {% if field.fieldTypeIdentifier == 'ezbinaryfile' %} + {% set ezbinaryfile_field = field %} + {% set break = true %} + {% endif %} + {% if break is defined %} + {% set break = loop.last %} + {% endif %} +{% endfor %} + +{% if location is defined and ezbinaryfile_field is not null %} + + {{ content.name }} + +{% else %} +

{{ content.name }}

+{% endif %}