More in this section

Forums / Developing with Sitefinity / Page Status of workflow enabled pages

Page Status of workflow enabled pages

6 posts, 0 answered
  1. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    18 Feb 2009
    Link to this post
    I have work flow enabled on my site.

    I have a control that reads the CMS site maps and displays links to the pages... But i am unable to figure out how to figure out if to display the page only if the page has god through approval and has been published...

    For example i have a page that is waiting for approval (so i would not want it displaying on the site) and i would not want it to display as a link until it have been approved and published.

    Sounds simple enoughm, i thought i would be able to figure this out by looking at the status of the page:

    if (currentPage.Status == PageStatus.Published) 
       source.Add(currentPage); 

    But this page, even though it has NOT been published yet comes back as status - you guessed it - published.....

    Could someone share with me how to find out the status of a page so that i can avoid adding it to my menu...

    Duncan
  2. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    18 Feb 2009
    Link to this post
    So the only option i have found that tells me if the current page is in the workflow process is this:

    1 Telerik.Workflow.WorkflowInstance PageWorkflow = currentPage.GetWorkflow(); 
    2 if (PageWorkflow == null
    3
    4    source.Add(currentPage); 
    5

    I have found that once the page is published currentPage.GetWorkflow() comes back null...

    If anyone has any other idea, let em know...

    Duncan
  3. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    18 Feb 2009
    Link to this post
    1 Telerik.Workflow.WorkflowInstance pageWorkflow = currentPage.GetWorkflow(); 
    2 if (pageWorkflow == null
    3
    4    source.Add(currentPage); 
    5
    Sorry some typos in last post

    Duncan
  4. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    19 Feb 2009
    Link to this post
    This is not really going to work for me actually. After playing with it a bit i noticed that if a page exists and an editor edits the page then the code above removes the live page from the menu because it has entered the work flow process...

    What i need to know is if the page is new and has not been published yet then don't show in the menu, but if the page is old and there is a version waiting for approval still show the link in the menu...

    Any help with this would be great guys, thank in advance...

    Duncan
  5. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    20 Feb 2009
    Link to this post
    Ok i figured this out... The following code checks if the page is new or is a previously published page... If it is new it checks the pages workflow status. If it is not new it adds it to the menu so that the user can still access the existing page...

    if (currentPage.Status == PageStatus.New) 
        WorkflowInstance workflow = currentPage.GetWorkflow(); 
        if (workflow != null
        { 
            PageWorkflow activity = (PageWorkflow)workflow.Activity; 
            if (activity.ApprovalStatus == ApprovalStatus.Published) 
            { 
                source.Add(currentPage); 
            } 
        } 
    else 
        source.Add(currentPage); 

    Hope this helps someone else. Thanks,

    Duncan
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Feb 2009
    Link to this post
    Hi Duncan,

    And just a follow up about getting the current page that is requested to complete Duncan's example.

            CmsManager cmsManager = new CmsManager(); 
            CmsSiteMapNode currentNode = (CmsSiteMapNode)SiteMap.Provider.CurrentNode; 
            ICmsPage editPage =  cmsManager.GetPage(currentNode.CmsPage.ID, trueas ICmsPage; 
     
            // change show in navigation depending on the workflow status 
            editPage = (ICmsPage)cmsManager.GetPage(currentNode.CmsPage.ID, true); 
            WorkflowInstance workflow = pageForEdit.GetWorkflow(); 
            PageWorkflow activity = (PageWorkflow)workflow.Activity; 
     
            if (activity.ApprovalStatus == ApprovalStatus.Published) 
            { 
               // do something here 
            } 
     
        } 
     
     

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
6 posts, 0 answered