How to get dynamic content by culture in multisite - On Premise – Configurations & Setup - On Premise – Configurations & Setup - Progress Community
 On Premise – Configurations & Setup

How to get dynamic content by culture in multisite

  • How to get dynamic content by culture in multisite
  • I have two site are Singapore site and China site,
    Inside Singapore have only English language
    Inside China have two language are English and Chinese
    Two site using a default module is "Executive",
    I add 4 item inside Executive module of Singapore site which are  "a, b, c, d", Then i go to China Site, i add Chinese culture for two item are "a,b"
    this is my code using to get all item Executive by Culture to show China Site, 

    var executiveData = DynamicModuleManager.GetManager().GetDataItems(executiveStaffType).Where(h => h.Status == ContentLifecycleStatus.Live && h.Visible && h.ApprovalWorkflowState == "Published")
                    .AsEnumerable().Where(p => p.PublishedTranslations.Contains(CurrentCulture));

    I see on front-end China Site show only two item "a,b" with English culture mode, 
    please help me show 4 item with English mode, and show 2 item in Chinese mode
    Note: when i debug i see with item c,d don't have any item inside PublishedTranslations property , so they can't show with above query
  • Hi,

    This is caused because you filter the items by culture. You are only getting the items that have a published translation in the current culture. You can get all the items by removing the extra filter like so:

    var executiveData = DynamicModuleManager.GetManager().GetDataItems(executiveStaffType).Where(h => h.Status == ContentLifecycleStatus.Live && h.Visible && h.ApprovalWorkflowState == "Published")
                    .AsEnumerable();

    Regards,
    Velizar Bishurov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  • I've added something like this to filter them.

    return _manager
                            .GetDataItems(Resolve(type))
                            .Where(live) //always get the live ones
                            .AsEnumerable()
                            .Where(x =>
                           

                                bool filterCulture = true;
                                if (!Thread.CurrentThread.CurrentCulture.Name.Equals("en"))
                               
                                    filterCulture = x.PublishedTranslations.Any(p => p.ToLower().Equals(Thread.CurrentThread.CurrentCulture.Name.ToLower()));
                               

                                return filterCulture;

                            ).AsQueryable();