Supposing you have a structure of products but you only want some to be available to certain localities?

I am sure you could add a field to the entries E.g (Available in: eng | fr) and then test the local in the template before listing the entires. However, I'm not sure this is the best way of approaching this.

Initially, it may be that the category the product is within dictates its availability in a country but this is not guaranteed in the future.

Any ideas appreciated.


Yeah, a simple checkboxes field with a list of the countries would be a good approach to realize this.

Another idea is to make use of the localization feature, which comes with a Craft Pro license. Then you'd add a new structure entry (in your case the product) in one locale (e.g. "fr"), save it, and all entered content is copied over to the other locales (e.g. "en" and "de").

After that you can switch over to another locale's version of that entry, and make individual edits for it (e.g. change "10 EUR" to "8 GBP"). To disable an entry completely for one locale, use the status lightswitch available for each locale separately at the top right of the info panel.

Craft CP - Lightswitch to toggle entry status for each locale

Don't read this as if this "localization feature" solution is the right one. Consider if you really need to translate entry fields (product infos etc.) into other languages1, if not I'd definitely do it like you initially intended.

And there's also a chance that you want to use both of these features combined: if you want to list all entry pages translated for each locale and additionally show the visitors where these products are available.


1. "Craft Personal and Craft Client store content on a per-locale basis too, so down the road if you want your site to cater to a second locale, Craft is already set up for it."

  • I am glad my approach sounds like it makes sense. In your other idea using the localization + new structure would I end up with multiple versions products to manage?
    – jamus
    Aug 14 '14 at 9:42
  • @jamus you don't need a new structure, just add a new locale to your site and you'd have the localization feature working on your old structure! And yes, you kind of have multiple versions of that product to manage (that's the actual purpose for the feature :D), but you can individually select the fields you want to be always in sync (if you change the value in one locale, it automatically changes in all others, too).
    – carlcs
    Aug 14 '14 at 16:48
  • I guess I'll have to have a play around to better grasp what you're saying. Thanks for your help (and starting point).
    – jamus
    Aug 15 '14 at 8:41
  • Yeah, it's probably best to not only think that through in theory alone. All I wanted to say is that you can hand-pick the fields you want to be translatable. You could even select no field at all and you'd end up with your product entries to be totally in sync across your locales and use only the lightswitch to disable it in certain locales. But that wouldn't make that much sense and I'd rather choose that other approach to handle this. If you start using the Localization feature, you'd rather do this to make the whole site being translated to other languages...
    – carlcs
    Aug 15 '14 at 9:10
  • ... Being able to select and deselect certain product entries for each locale would only be a nice side-effect of that, @jamus!
    – carlcs
    Aug 15 '14 at 9:12

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.