Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions config/app/prepends/ibexa/content_view.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want downloadable ng_video?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't come up with a specific use case, but I added ng_video because both file and ng_video content types have field of type ezbinaryfile.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pspanja WDYT?

- 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"
Expand Down
26 changes: 26 additions & 0 deletions templates/themes/app/content/parts/content_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
21 changes: 21 additions & 0 deletions templates/themes/app/content/views/download_inline.html.twig
Original file line number Diff line number Diff line change
@@ -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 %}
<a href="{{ path('ngsite_download', { 'contentId': content.id, 'fieldId': ezbinaryfile_field.id, 'isInline': 1 }) }}" class="{{ css_class }}">
{{ content.name }}
</a>
{% else %}
<p>{{ content.name }}</p>
{% endif %}
Original file line number Diff line number Diff line change
@@ -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 %}
<a href="{{ path('ngsite_download', { 'contentId': content.id, 'fieldId': ezbinaryfile_field.id, 'isInline': 1 }) }}" class="{{ css_class }}">
{{ content.name }}
</a>
{% else %}
<p>{{ content.name }}</p>
{% endif %}
21 changes: 21 additions & 0 deletions templates/themes/app/content/views/download_link.html.twig
Original file line number Diff line number Diff line change
@@ -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 %}
<a href="{{ path('ngsite_download', { 'contentId': content.id, 'fieldId': ezbinaryfile_field.id, 'isInline': 0 }) }}" class="{{ css_class }}">
{{ content.name }}
</a>
{% else %}
<p>{{ content.name }}</p>
{% endif %}
21 changes: 21 additions & 0 deletions templates/themes/app/content/views/download_link/common.html.twig
Original file line number Diff line number Diff line change
@@ -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 %}
<a href="{{ path('ngsite_download', { 'contentId': content.id, 'fieldId': ezbinaryfile_field.id, 'isInline': 0 }) }}" class="{{ css_class }}">
{{ content.name }}
</a>
{% else %}
<p>{{ content.name }}</p>
{% endif %}