Skip to content

IBX-6554: Prevent Twig errors when location is not defined in Location View #1517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: 4.6
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{% set location_path = location.pathString %}

{% extends "@ibexadesign/ui/layout.html.twig" %}

{% trans_default_domain 'ibexa_locationview' %}
Expand Down Expand Up @@ -29,7 +27,7 @@
{{ ibexa_render_component_group('content-tree-before') }}
<div class="ibexa-content-tree-container"
data-tree-root-location-id="{{ content_tree_module_root|default(ibexa_admin_ui_config['contentTree']['treeRootLocationId']) }}"
data-current-location-path="{{ location_path|default('') }}"
data-current-location-path="{{ location is defined and location is not null ? location.pathString : '' }}"
style="{{ content_tree_width_style }}"
>
<div class="ibexa-content-tree-container__root"></div>
Expand Down Expand Up @@ -57,7 +55,9 @@
{% endblock %}

{% block context_menu %}
{% set content_sidebar_right = knp_menu_get('ezplatform_admin_ui.menu.content.sidebar_right', [], {'location': location, 'content': content, 'content_type': content_type}) %}
{% set content_sidebar_right = location is defined and location is not null
? knp_menu_get('ezplatform_admin_ui.menu.content.sidebar_right', [], {'location': location, 'content': content, 'content_type': content_type})
: [] %}
{{ knp_menu_render(content_sidebar_right, {'template': '@ibexadesign/ui/menu/context_menu.html.twig'}) }}

<div class="ibexa-extra-actions-container">
Expand Down Expand Up @@ -109,23 +109,25 @@
{% endblock %}
{% endembed %}

{% if location.hidden or location.invisible %}
<div class="pb-4">
{% include '@ibexadesign/ui/component/alert/alert.html.twig' with {
type: 'info',
title: 'content.hidden.message'|trans()|desc('This Content item or its Location is hidden.'),
icon_path: ibexa_icon_path('hide'),
class: 'mb-4',
} only %}
</div>
{% if location is defined and location is not null %}
{% if location.hidden or location.invisible %}
<div class="pb-4">
{% include '@ibexadesign/ui/component/alert/alert.html.twig' with {
type: 'info',
title: 'content.hidden.message'|trans()|desc('This Content item or its Location is hidden.'),
icon_path: ibexa_icon_path('hide'),
class: 'mb-4',
} only %}
</div>
{% endif %}
{{ ibexa_render_component_group(
'location-view-content-alerts',
{
'versionInfo': content.versionInfo,
'location': location,
}
) }}
{% endif %}
{{ ibexa_render_component_group(
'location-view-content-alerts',
{
'versionInfo': content.versionInfo,
'location': location,
}
) }}
{% endblock %}

{% block content %}
Expand All @@ -134,20 +136,22 @@
<div class="panel panel-primary">
<div class="panel-body">
{# 'is_location_visible': location.invisible - param deprecated since EZP-32395 #}
{{ ibexa_render_component_group('location-view-tab-groups', {
'content': content,
'location': location,
'contentType': content_type,
'draft_pagination_params': draft_pagination_params,
'reverse_relation_pagination_params': reverse_relation_pagination_params,
'relation_pagination_params': relation_pagination_params,
'custom_urls_pagination_params': custom_urls_pagination_params,
'system_urls_pagination_params': system_urls_pagination_params,
'roles_pagination_params': roles_pagination_params,
'policies_pagination_params': policies_pagination_params,
'is_location_visible': not location.invisible,
'subitems_module': subitems_module,
}) }}
{% if location is defined and location is not null %}
{{ ibexa_render_component_group('location-view-tab-groups', {
'content': content,
'location': location,
'contentType': content_type,
'draft_pagination_params': draft_pagination_params,
'reverse_relation_pagination_params': reverse_relation_pagination_params,
'relation_pagination_params': relation_pagination_params,
'custom_urls_pagination_params': custom_urls_pagination_params,
'system_urls_pagination_params': system_urls_pagination_params,
'roles_pagination_params': roles_pagination_params,
'policies_pagination_params': policies_pagination_params,
'is_location_visible': not location.invisible,
'subitems_module': subitems_module,
}) }}
{% endif %}

{% if content_type.isContainer %}
{{ form_start(form_subitems_content_edit, { 'action': path('ibexa.content.edit'), 'attr': { 'hidden': 'hidden' }}) }}
Expand All @@ -165,7 +169,7 @@
</div>
</div>
</div>
{% if content_has_reverse_relations and not location.contentInfo.isHidden %}
{% if content_has_reverse_relations and location is defined and location is not null and not location.contentInfo.isHidden %}
{% include '@ibexadesign/content/modal/hide_confirmation.html.twig' %}
{% endif %}
</div>
Expand Down
Loading