Skip to content

Commit 93b3d54

Browse files
authored
Fix download media with different locales in admin panel (#105)
Set the proper localeCode based on the selected channel, not on the user administrator language. | Q | A | --------------- | ----- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | fixes #78 | License | MIT
2 parents 51d3675 + 240cc65 commit 93b3d54

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
<div class="col-12">
2-
<label for="sylius_cms_media_path" class="form-label"> {{ 'sylius_cms.ui.preview'|trans }}</label>
3-
<a class="btn" href="{{ path('sylius_cms_shop_media_download', {'code': code}) }}">
4-
{{ ux_icon('tabler:download') }}
5-
{{ 'sylius_cms.ui.download'|trans }}
6-
</a>
7-
</div>
1+
{% set localeCode = null %}
2+
{% set channels = hookable_metadata.context.form.channels.vars.choices %}
3+
4+
{% set checkedChannels = hookable_metadata.context.form.children.channels.vars.value %}
5+
6+
{% for channel in channels %}
7+
{% if localeCode == null %}
8+
{% if channel.data.enabled and channel.data.code in checkedChannels %}
9+
{% set localeCode = channel.data.defaultLocale.code %}
10+
{% endif %}
11+
{% endif %}
12+
{% endfor %}
13+
14+
{% if localeCode != null %}
15+
<div class="col-12">
16+
<label for="sylius_cms_media_path" class="form-label"> {{ 'sylius_cms.ui.preview'|trans }}</label>
17+
<a class="btn" href="{{ path('sylius_cms_shop_media_download', {'code': code, '_locale': localeCode}) }}">
18+
{{ ux_icon('tabler:download') }}
19+
{{ 'sylius_cms.ui.download'|trans }}
20+
</a>
21+
</div>
22+
{% endif %}

0 commit comments

Comments
 (0)