Try Now
More in this section

Forums / Developing with Sitefinity / Getting content regardless of status

Getting content regardless of status

2 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    05 Aug 2010
    11 Dec 2010
    Link to this post

    I've got a module that allows members to add content items. These content items are shown on the front-end website, once that user has logged in. The module has a UserID metafield, so I can easily show the logged-in user just the content items that belong to him/her. I use the following code to do so:

    //create an instance of the contentmanager
    this._oContentMgr = new ContentManager(PublicationsManager.DefaultContentProvider);
    //get all publications
    //filter content items based on userID
    List<IMetaSearchInfo> oFilter = new List<IMetaSearchInfo>();
    oFilter.Add(new MetaSearchInfo(MetaValueTypes.ShortText, "UserID", Membership.GetUser().ProviderUserKey.ToString(), SearchCondition.Equal));
    IList oContentItems = _oContentMgr.GetContent(0, 0, "Name ASC", oFilter.ToArray());

    If I login to the SiteFinity Admin and look at the current content items, there are three. 2 are ForApproval, although they have been published previously (they have just been updated) and 1 is Published. When I run the code above all 3 records that are returned have a status of Published. I'm sure that is By Design because generally you want GetContent to return the latest published version of each content.

    My scenario is that I want the logged-in user to see whether the latest version they updated has been published. I can loop through the IversionItem for each Content Item, but the IVersionItem doesnt indicate whether it is the published version. Is there anyway of working out whether the latest IVersionItem is published? The only way I can think of doing it is to compare the IVersionItem.Data[N].Data against ContentItem.GetMetaData("MetaFieldKey") and check whether each one of them is the same. Any better ideas?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    25 Oct 2016
    11 Dec 2010
    Link to this post
    Hello higgsy,

    IVersionItem does not indicate whether the item has been published, but it shows the workflow ID. Whether the item is published or send for approval depends on the workflow. This is why you have to get all IVersionItems then get the userID metakey and work with the WorkflowInstance where you can pass the workflow id to WorkflowRuntime.Instance.GetWorkflow(Guid id); Then you can check whether an item is approved , published etc.

    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered