+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Get Available Cultures Dynamic Content

Get Available Cultures Dynamic Content

4 posts, 1 answered
  1. Jared
    Jared avatar
    122 posts
    Registered:
    04 Apr 2013
    03 Mar 2014
    Link to this post

    I have a custom content type that I am attempting to get the available cultures for the item in my custom workflow.  I have done this via Pages with the following

    :var page = item.GetValue(context.DataContext) as ISecuredObject;
    var pageManager = PageManager.GetManager();
    var node = pageManager.GetPageNode(page.Id);

     List<System.Globalization.CultureInfo> pageCultures = new List<System.Globalization.CultureInfo>(node.AvailableCultures);

    This does not work the same way with my Dynamic Content.   Has anyone done anything similar to what I am trying to accomplish?  

  2. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    06 Dec 2016
    04 Mar 2014
    Link to this post
    Hi,

    To get the available cultures of items of custom modules created by Module Builder you could use:

    DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
               Type testType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Test.Test");
               var testItems = dynamicModuleManager.GetDataItems(testType).Where(i => i.Status == ContentLifecycleStatus.Live).ToList();
               foreach (var item in testItems)
               {
                   var cultures = item.AvailableCultures.ToList();
               }


    Regards,
    Stefani Tacheva
    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. Jared
    Jared avatar
    122 posts
    Registered:
    04 Apr 2013
    04 Mar 2014 in reply to Stefani Tacheva
    Link to this post

    I will try this out and see what I get.  To take this a step farther.  I am creating custom workflow for all my Dynamic Content.  I am having troubles getting the workflow item and the properties associated with it.  I did a workflow for pages and did not have issues.  I tried to replicate the logic I used for pages and I am having troubles.

    For the content item I did got all values of the properties: 

    var dataContext = context.DataContext;
    var item = dataContext.GetProperties();

    Then, I got every value for all 16 properties that exist:

    var item = dataContext.GetProperties()["workflowItem"];
    var item1 = dataContext.GetProperties()["masterFluent"];
    var item2 = dataContext.GetProperties()["fluent"];
    var item3 = dataContext.GetProperties()["currentPrincipal"];
    var item4 = dataContext.GetProperties()["itemStatus"];
    var item5 = dataContext.GetProperties()["IsItemPublished"];
    var item6 = dataContext.GetProperties()["handle"];
    var item7 = dataContext.GetProperties()["operationName"];
    var item8 = dataContext.GetProperties()["workflowDefinitionID"];
    var item9 = dataContext.GetProperties()["itemId"];
    var item10 = dataContext.GetProperties()["applicationName"];
    var item11 = dataContext.GetProperties()["contextBag"];
    var item12 = dataContext.GetProperties()["workflowDefinition"];
    var item13 = dataContext.GetProperties()["isCheckedOut"];
    var item14 = dataContext.GetProperties()["result"];
    var item15 = dataContext.GetProperties()["providerName"];

     Next, I got each value for each property while I was in debug mode:



    Now the question is, what property do I use in order to get the values of the actual workflow item itself?  I have tried many different things and nothing seems to work.  I think I may not be setting the value to the correct class type.  For example, is the following correct (which I thought is what I need from the start):

    var dataContext = context.DataContext;
    var item = dataContext.GetProperties()["workflowItem"];
    var module = item.GetValue(dataContext) as AnyDraftFacade;

    By doing this, all values are null in my variable "module".  Thoughts?

     

  4. Jared
    Jared avatar
    122 posts
    Registered:
    04 Apr 2013
    05 Mar 2014 in reply to Stefani Tacheva
    Link to this post

    I have done the following to get the available cultures:

    protected override void Execute(CodeActivityContext context)
            {
                var dataContext = context.DataContext;
                var manager = DynamicModuleManager.GetManager();
     
                //Get Item Obect
                var masterFluent = (MasterFacade)dataContext.GetProperties()["masterFluent"].GetValue(dataContext);
     
                //Get Module
                var module = masterFluent.Get();
                //Get Module Type
                Type type = module.GetType();
                //Get Data Item
                var item = manager.GetDataItem(type, module.Id);
     
                List<System.Globalization.CultureInfo> itemCultures = new List<System.Globalization.CultureInfo>(item.AvailableCultures);
    }

    Answered
4 posts, 1 answered