kopia lustrzana https://github.com/wagtail/wagtail
Add {% if page %} around language selector example
As suggested here: https://stackoverflow.com/questions/65065301/wagtail-not-redirecting-500-error-instead-of-404-when-debug-false/65065608?noredirect=1#comment115125518_65065608pull/6622/head
rodzic
06c3c3a24b
commit
4dc9f81d68
|
@ -338,15 +338,25 @@ this into account.
|
|||
{# make sure these are at the top of the file #}
|
||||
{% load i18n wagtailcore_tags %}
|
||||
|
||||
{% for translation in page.get_translations.live %}
|
||||
{% get_language_info for translation.locale.language_code as lang %}
|
||||
<a href="{% pageurl translation %}" rel="alternate" hreflang="{{ language_code }}">
|
||||
{{ lang.name_local }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% if page %}
|
||||
{% for translation in page.get_translations.live %}
|
||||
{% get_language_info for translation.locale.language_code as lang %}
|
||||
<a href="{% pageurl translation %}" rel="alternate" hreflang="{{ language_code }}">
|
||||
{{ lang.name_local }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
Let's break this down:
|
||||
|
||||
.. code-block:: html+Django
|
||||
|
||||
{% if page %}
|
||||
...
|
||||
{% endif %}
|
||||
|
||||
If this is part of a shared base template it may be used in situations where no page object is available, such as 404 error responses, so check that we have a page before proceeding.
|
||||
|
||||
.. code-block:: html+Django
|
||||
|
||||
{% for translation in page.get_translations.live %}
|
||||
|
|
Ładowanie…
Reference in New Issue