More in this section

Forums / Developing with Sitefinity / Change settings to sort by status in modules

Change settings to sort by status in modules

2 posts, 0 answered
  1. Bart Welch
    Bart Welch avatar
    64 posts
    Registered:
    10 Jul 2009
    09 Nov 2009
    Link to this post
    Is there a setting we can change in order to sort by the status of modules under the modules tab?  We have workflow setup and need to be able to sort by status in order to approve and publish the appropriate modules.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Nov 2009
    Link to this post
    Hi Bart Welch,

    There is no build in functionality for filtering content items by workflow status. Actually there is a way to implement this.

    1. Create a new metakey for your content item. This metakey will be used for saving the status of the workflow.
    2. Then we can easily use the search option from the backend to get items with certain workflow status.

    1. Map the Preview template for the desired provider - for instance I am going to show you have you can achieve this with News module.

    1. Map NewsItemPreview template and create a code behind of this template. Then add the following logic to it

    protected void Page_Load(object sender, EventArgs e)
       {
           workflowMenu.Command += new CommandEventHandler(workflowMenu_Command);
       }
     
       void workflowMenu_Command(object sender, CommandEventArgs e)
       {
           WorkflowInstance instance = ((WorkflowMenu)sender).GetWorkflow();
           if (instance != null)
           {
               List<EventActivity> commands = new List<EventActivity>();
               this.LoadCommands(commands, instance.Activity.Activities);
               int idx = int.Parse((string)e.CommandArgument);
             
              
     
               // The workflow events you could handle are: SendForApproval, Approve, Decline, Publish
               if ((commands.Count > idx) && !(commands[idx].CommandName.Equals("Publish")))
               {
                   // Getting currently modified content and format the message
                   NewsItemPreview itemPreview = (NewsItemPreview)this.Parent.Parent;
                   Guid contentID = new Guid(CmsHttpRequest.Current.QueryStirng[itemPreview.ParameterKey]);
     
                   // here you should work with staged content
                   StagedContent content = itemPreview.Manager.GetCurrentState(contentID);
     
                   NewsManager nm = new NewsManager("News");
     
     
                   switch (commands[idx].CommandName)
                   {
                       case "SendForApproval":
     
                           content.SetMetaData("Meta1", "SendForApproval");
                           nm.Content.SavedStagedContent(content, ContentStatus.Published);
                                    
                           break;
                       case "Approve":
                           content.SetMetaData("Meta1", "Approve");
                           nm.Content.SavedStagedContent(content, ContentStatus.Published);
                     
     
                           break;
     
     
                           content.SetMetaData("Meta1", "Decline");
                           nm.Content.SavedStagedContent(content, ContentStatus.Published);
                           break;
     
     
     
                       case "Publish":
                           content.SetMetaData("Meta1", "Publish");
                           nm.Content.SavedStagedContent(content, ContentStatus.Published);
                           break;
                   }
               }
           }
       }
     
       private void LoadCommands(List<EventActivity> commands, IList<Activity> activities)
       {
           foreach (Activity act in activities)
           {
               if (act is EventActivity)
                   commands.Add((EventActivity)act);
               this.LoadCommands(commands, act.Activities);
           }
       }

    Then you can use the built in search of the view to get the items - There is a dropdown from where you can select your metakey and seachbox where you can type your criteria - the value of our metakey - say SendForApproval .

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered