2

I’m trying to build an XML sitemap that contains all entries including those in a different locale. I thought the localeEnabled(false) would allow entries for all locales to be displayed, however, the following doesn’t seem to work:

{% set pages = craft.entries.section('pages').status('live').localeEnabled(false) %}

If is assign a locale:

{% set pages = craft.entries.section('pages').status('live').locale('de') %}

then the entry is displayed.

I have tried using .locale(null) and .localeEnabled(null) without success.

Any ideas?

2

Not sure, but I think the only way is to query for each locale and merge.

{% set siteLocales = craft.i18n.getSiteLocales %}
{% set pages = [] %}
{% for locale in siteLocales %}
    {% set localePages = craft.entries.section('pages').locale(locale.getId).find() %}
    {% set pages = pages|merge(localePages) %}
{% endfor %}

{% for page in pages %}
    {{ page.title}}
{% endfor %}
  • Thanks Douglas. That definitely captures all the entries for all locales so I will use this method, but I am curious why the purpose of localeEnabled(false). In the docs it suggests would displays all entries irrespective of locale. – Simon Leadbetter May 1 '15 at 12:20
  • Having thought about this, I think this may be a bug. I’ll report it to P&T to see what they say. – Simon Leadbetter May 1 '15 at 12:30
  • I think localeEnabled(false), means display an entry that otherwise wouldn't show because it is not localeEnabled (in settings) for that locale. I don't think it has anything to do with showing other locales. – Douglas McDonald May 1 '15 at 13:45
  • Ah. That kind of makes sense. Thanks for taking the time to help with this. I’ll run with your solution. – Simon Leadbetter May 1 '15 at 13:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.