0
votes

I'm using Kentico 11 and would like to get the current site's available site cultures using a Macro.

I am trying to do this from a Page Type field's data source Macro Expression. I have set the data type to Text and the Form Control to Multi Select.

The reason I am doing this is because our client has requested that some products only be available to specific site cultures (They are using site culture as locations).

2

2 Answers

1
votes

Yes. You can {%SiteContext.CurrentSite.OtherBindings.CultureSites.ItemsAsFields.CultureID%}. This will give you the list of CultureIDs available for your site. To explore available macros and test them I suggest you go system->macros->console

The following will output CultureID, CultureCode, CultureName: {%SiteContext.CurrentSite.OtherBindings.CultureSites.Transform("{#CultureID#} {#Parent.CodeName#} {#Parent.CultureName#}<br>")%}

0
votes

This situation would be better handled via custom SQL query on CMS_SiteCulture and join on CMS_Culture table.

Out of the box macros do not provide direct access to this binding and you would have to resort to custom macro to get a proper list(array) of items back.