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

Forums / Developing with Sitefinity / How to use Sitefinity News API ?

How to use Sitefinity News API ?

2 posts, 0 answered
  1. rent
    rent avatar
    104 posts
    Registered:
    05 May 2008
    12 Mar 2009
    Link to this post

    In my Sitefinity web site I want to get access to news from Sitefinity News API by this code:

    NewsManager newsManager = new NewsManager("News");
    IList contents = newsManager.Content.GetContent();
    for (int i = 0; i < contents.Count; i++)
    {
    RadComboBoxItem ComdoItem = new RadComboBoxItem();
    IContent cont = contents[i] as IContent;
    ComdoItem.Text = cont.ID.ToString();
    newsManager.Content.CreateContent("123456");
    CategorySelect.Items.Add(ComdoItem);
    }

    Where CategorySelect is RadComboBox component. This code is my bad attempt to understand News module API. 

    How to get access to news from API ? How to add, view and modify news using Sitefinity News API ?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Mar 2009
    Link to this post
    Hello rent,

    News is GenericContent based module.

    1. How to add GC items/News

           ContentManager contentManager = new ContentManager("News"); 
           // create an empty content 
           IContent newContent = contentManager.CreateContent("text/html"); 
           newContent.Content = "Here is my custom content here"
           // set meta keys for the content item 
           newContent.SetMetaData("Title""MyTitle"); 
           newContent.SetMetaData("Author""Admin"); 
            //save the content 
            contentManager.SaveContent(newContent); 

    To get content you can call GetContent method and then modify it. More information at http://www.sitefinity.com/help/developer-manual/news-api-overview.html

    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.
2 posts, 0 answered