More in this section
Forums / Deployment / How to get dynamic content by culture in multisite

How to get dynamic content by culture in multisite

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. tin
    tin avatar
    2 posts
    Registered:
    22 May 2015
    26 Aug 2015
    Link to this post
    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
  2. Velizar Bishurov
    Velizar Bishurov avatar
    143 posts
    Registered:
    18 Sep 2017
    31 Aug 2015
    Link to this post
    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
     
  3. Jayson
    Jayson avatar
    3 posts
    Registered:
    23 Oct 2015
    08 Mar 2016 in reply to Velizar Bishurov
    Link to this post
    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();

3 posts, 0 answered