2

I have a craft2 site running quite happily with 8 languages.

I noticed recently that a dropdown selection of category entries is not working when the locale is changed to chinese (locale = 'zh').

So the list of countries to search on does not render fully - only some countries are shown.

Here is the real world example https://seafarerhelp.org/en/seafarers-directory https://seafarerhelp.org/zh/seafarers-directory

check out the search country dropdown. It is using this template code:

{% set countries = craft.categories({
    group: 'locations',
    limit: null,
    level: 1,
    order:['title asc']
   })
%}

In english we get the full list. In Chinese (select the locale) we get only a handful.

Other countries seem fine. I am stumped. Have looked for oddities in structure but can find none. Ironically this area of the site is not translated but this doesn't present any problem with other locales/languages

  • Did you get this sorted? I’m seeing the same 9 locales on each of those links. – Brandon Kelly Jul 24 '18 at 5:23
  • It's the country dropdown search box. So when you view in english and select the country to search the port directory, you get all countries. When you change to chinese, we get only 12 countries in the drop down search. – joomkit Jul 24 '18 at 8:41
  • Ah gotcha. Have you verified that all of those entries are enabled for the ZH site? As a quick test you can add localeEnabled: false to your category criteria params. – Brandon Kelly Jul 24 '18 at 13:36
  • I guess by enabled you mean the category entires settings are all available from translation? No content entries are pulled in the query. Added the param no difference....(Shame the Craft3 debugger isn't available - like that a lot). Kinda weird that all the other locales are ok. Content editor mistakenly added chinese to titles for some chinese entries but cant see why this would affect the categories.... – joomkit Jul 24 '18 at 16:03
  • Hm ok, not sure off the top of my head then. Can you email a database backup and a simple example template that illustrates the issue? support@craftcms.com – Brandon Kelly Jul 24 '18 at 22:26
2

This ended up being because not all categories were properly resaved after a new locale was added. Resaving the categories solved it.

  • Thanks for the help Brandon - I bless the day i started using craft cms even with the odd hiccup it beats every other cms i have used – joomkit Aug 6 '18 at 8:23
  • I'm pretty sure this is a bug, yeah? Re-saving the categories fixed the problem for me too but it's pretty time consuming and I shouldn't have to do that in the first place. – kmgdev Dec 27 '18 at 3:06
  • @kgrote a background task that resaves all categories is supposed to get queued up automatically after adding a locale. – Brandon Kelly Dec 28 '18 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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