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

Forums / Developing with Sitefinity / News API and Workflow

News API and Workflow

7 posts, 2 answered
  1. Nauman
    Nauman avatar
    35 posts
    Registered:
    28 Jul 2008
    26 Apr 2010
    Link to this post
    Hi

    I am displaying news items on the website using new api, i enabled workflow for the news module but some how it is not working with the news api. As i created a new news item it displayed on the website even the news item is not approved.

    Please help what i am missing.

    Thanks
    Nauman Ahmed
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    26 Apr 2010
    Link to this post
    Hello Nauman,

    What is the code you use to display the items? It is possible that you see the published version, but not the staged that is used in the workflow.

    Sincerely yours,
    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.
  3. Nauman
    Nauman avatar
    35 posts
    Registered:
    28 Jul 2008
    26 Apr 2010
    Link to this post
    Thanks Ivan Dimitrov  for your immediate help
    here is the code snippet  for displaying the latest news item


    // create new instance of NewsManager
    Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager("News");
     
    // get all news content items & sorting
    IList listOfNewsItems = contentManager.GetContent("Publication_Date DESC");
     
    if (listOfNewsItems.Count > 0)
    {
    //getting the first new item
    Telerik.Cms.Engine.IContent newsItem = (Telerik.Cms.Engine.IContent)listOfNewsItems[0];               
    RecentNews.Content = newsItem.Content.ToString();
    RecentNews.Publication_Date = newsItem.GetMetaData("Publication_Date").ToString();            
    RecentNews.Summary = newsItem.GetMetaData("Summary").ToString();                               
    RecentNews.Url = newsItem.Url;               
    }

    As i create the news items it display on the website with out  going through the complete cycle of workflow.

    Many Thanks
    Nauman Ahmed
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    26 Apr 2010
    Link to this post
    Hello Nauman,

    Try using the highlighted overload

    Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager("News");
     
           IList listOfNewsItems = contentManager.GetContent("Publication_Date DESC");
           if (listOfNewsItems.Count > 0)
           {
                   var l = contentManager.GetContent(0, 0, "Publication_Date DESC", ContentStatus.Published);
                   IContent newsItem = (IContent)l[0];
                   Response.Write(newsItem.Content.ToString() + "<br />");
                   Response.Write(newsItem.GetMetaData("Publication_Date").ToString() + "<br />");
                   Response.Write(newsItem.GetMetaData("Summary").ToString() + "<br />");
                   Response.Write(newsItem.Url.ToString() + "<br />");
                   Response.Write("=======");
     
           }


    Greetings,
    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.
    Answered
  5. Nauman
    Nauman avatar
    35 posts
    Registered:
    28 Jul 2008
    26 Apr 2010
    Link to this post
    Yahoooooo! it works .

    Many Thanks Ivan Dimitrov

    Kind Regards
    Nauman Ahmed
  6. Nauman
    Nauman avatar
    35 posts
    Registered:
    28 Jul 2008
    27 Apr 2010
    Link to this post
    Hi Ivan Dimitrov

    One more related question

    Filter news with tags and news items whose status published

    NewsManager newsManager = new NewsManager("News");
     
    List<IMetaSearchInfo> emptyFilters = new List<IMetaSearchInfo>();
    List<Guid> emptyGuid = new List<Guid>();
    //filter news with tags and published
    IList listOfTagsFilterNewsItems = newsManager.Content.GetContent(0, 0, string.Empty, tagName, ContentStatus.Published, string.Empty, emptyGuid.ToArray(), emptyFilters.ToArray());

    But it's not working. Need help

    Thanks
    Nauman Ahmed

  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    27 Apr 2010
    Link to this post
    Hi Nauman,

    Try this

    var list = newsManager.Content.GetContent(0, 0, string.Empty, tagName, ContentStatus.Published, null, new Guid[]{});


    Best wishes,
    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.
    Answered
Register for webinar
7 posts, 2 answered