I disabled translation for Spanish and it returned 404 page.
I set all my fields to translatable and By default craft translations are empty.
How can I return English by default? Using Spanish locale
Thanks! :)
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communityI disabled translation for Spanish and it returned 404 page.
I set all my fields to translatable and By default craft translations are empty.
How can I return English by default? Using Spanish locale
Thanks! :)
By disabling a locale for an entry you are removing the automatically created route for this entry and locale (→ docs for routing).
But what you can do, is to diable the automatic routing (uncheck "Entries in this section have their own URLs" in the section settings) and add the same routes as custom dynamic routes manually.
news/{slug}
→ news/_entry
Those manual routes won't 404 for disabled entries and you can have some logic in your _entry.html template.
{% set entry = craft.entries.section('news').slug(slug).first() %}
{% if not entry %}
{% set entry = craft.entries.section('news').slug(slug).locale('en').first() %}
{% set duplicateContent = true %}
{% endif %}
{% if not entry %}
{% exit 404 %}
{% endif %}
I would also recommend to set your meta tags accordingly and make search engines aware of the duplicated content. I updated the code with a new variable definition, test if it is defined in your _layout main template.
exit 404
tag is no uncommon practice in Craft!