Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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:
ezbinaryfile_common:
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.

We can just name this common. No need for ezbinaryfile_ prefix. Same goes for template file names.

Copy link
Copy Markdown
Author

@AntePrkacin AntePrkacin Jul 10, 2025

Choose a reason for hiding this comment

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

a77e69a
Renamed ezbinaryfile_common.html.twig templates to just be common.html.twig. Updated the content_view.yaml file to reflect this change as well

template: "@ibexadesign/content/views/download_inline/ezbinaryfile_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:
ezbinaryfile_common:
template: "@ibexadesign/content/views/download_link/ezbinaryfile_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
28 changes: 27 additions & 1 deletion templates/themes/app/content/parts/content_fields.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{# content \Netgen\IbexaSiteApi\API\Values\Content #}
{# content \Ibexa\Contracts\Core\Repository\Values\Content\Content #}
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.

Are you sure this change is correct? We don't work with Ibexa Content.

Copy link
Copy Markdown
Author

@AntePrkacin AntePrkacin Jul 10, 2025

Choose a reason for hiding this comment

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

30358e1
My bad, reverted the change here


{% extends '@IbexaCore/content_fields.html.twig' %}

Expand Down 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 ezBinaryFileField = null %}
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.

Twig variables should be snake_case.

Copy link
Copy Markdown
Author

@AntePrkacin AntePrkacin Jul 10, 2025

Choose a reason for hiding this comment

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

dd4ee2b
Changed variable names to be snake_case

{% for field in content.fields %}
{% if field.fieldTypeIdentifier == 'ezbinaryfile' %}
{% set ezBinaryFileField = field %}
{% set break = true %}
{% endif %}
{% if break is defined %}
{% set break = loop.last %}
{% endif %}
{% endfor %}

{% if location is defined and ezBinaryFileField is not null %}
<a href="{{ path('ngsite_download', { 'contentId': content.id, 'fieldId': ezBinaryFileField.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 ezBinaryFileField = null %}
{% for field in content.fields %}
{% if field.fieldTypeIdentifier == 'ezbinaryfile' %}
{% set ezBinaryFileField = field %}
{% set break = true %}
{% endif %}
{% if break is defined %}
{% set break = loop.last %}
{% endif %}
{% endfor %}

{% if location is defined and ezBinaryFileField is not null %}
<a href="{{ path('ngsite_download', { 'contentId': content.id, 'fieldId': ezBinaryFileField.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 ezBinaryFileField = null %}
{% for field in content.fields %}
{% if field.fieldTypeIdentifier == 'ezbinaryfile' %}
{% set ezBinaryFileField = field %}
{% set break = true %}
{% endif %}
{% if break is defined %}
{% set break = loop.last %}
{% endif %}
{% endfor %}

{% if location is defined and ezBinaryFileField is not null %}
<a href="{{ path('ngsite_download', { 'contentId': content.id, 'fieldId': ezBinaryFileField.id, 'isInline': 0 }) }}" 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 ezBinaryFileField = null %}
{% for field in content.fields %}
{% if field.fieldTypeIdentifier == 'ezbinaryfile' %}
{% set ezBinaryFileField = field %}
{% set break = true %}
{% endif %}
{% if break is defined %}
{% set break = loop.last %}
{% endif %}
{% endfor %}

{% if location is defined and ezBinaryFileField is not null %}
<a href="{{ path('ngsite_download', { 'contentId': content.id, 'fieldId': ezBinaryFileField.id, 'isInline': 0 }) }}" class="{{ css_class }}">
{{ content.name }}
</a>
{% else %}
<p>{{ content.name }}</p>
{% endif %}