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

Forums / Developing with Sitefinity / Creating Custom Content via the Fluent API

Creating Custom Content via the Fluent API

6 posts, 0 answered
  1. Shane
    Shane avatar
    5 posts
    Registered:
    14 Apr 2011
    19 Jul 2011
    Link to this post
    I did some research around reading content from an RSS feed and importing it into the system using the Fluent API.  This works great for out of the box type of content (I was able to successfully add a news item utilizing this method).  However, I want to accomplish the same thing but using a custom content type that we've created in code.  I looked at the Products sample that is in the SDK and actually added that project as a reference to my web project.  However, I can't figure out how to access this custom content type via the Fluent API to work with the solution I've come up.

    Here's the code that handles submitting RSS content as a NewsItem.

    protected void btnNews_Click(object sender, EventArgs e)
    {
        // Get the RSS feed from Sitefinity Watch
     
        // Get the RSS items from the feed
        var rssItems = from item in newsRSS.Descendants("item")
                        select item;
     
        // Loop through each RSS item
        foreach (var item in rssItems.ToList())
        {
            //get the dictionary of items
            Dictionary<string, string> content = ParseRSS(item.Element("description").Value);
     
            // Add the news content via the RSS feed
            using (var fluent = App.WorkWith())
            {
                var news = fluent.NewsItem().CreateNew()
                .Do(b =>
                {
                    b.Title = content["title"];
                    b.Content = content["body"];
                    b.Author = content["author"];
                    b.SourceSite = content["source"];
                })
                .Get();
            }
        }
    }

    How can access the ProductItem (that is created in the Products example in the SDK) to work with the fluent API so I can access it via App.WorkWith()?
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    16 Aug 2017
    21 Jul 2011
    Link to this post
    Hi Shane,

    The fluent API is a wrapper of the normal API (managers and providers) and is implemented specifically for each module(News ,blogs ...). If you want to use Fluent API for a custom module( the products module is not built in so it is counted as cutom), you need to implement it yourself which is a hard task. As a different option is to convert the Products Item information to Rss with a third party service like for example web2rss, feedfire or similar.


    Regards,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Shane
    Shane avatar
    5 posts
    Registered:
    14 Apr 2011
    21 Jul 2011
    Link to this post
    So my problem isn't converting the information into RSS; rather its taking an external RSS feed and pull that into a custom content type.  Is there a way that I can do this without using the Fluent API but rather just sitefinity's standard API to instantiate a new instance of the ProductItem, set its properties, and then add it to the system so I can load custom content from an external source?

    Thanks
    Shane
  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    16 Aug 2017
    25 Jul 2011
    Link to this post
    Hello Shane,

    You can not use API to query a custom module yet. We will provide an new functionality to the API in Q2 release .

    All the best,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Mark
    Mark avatar
    20 posts
    Registered:
    15 Oct 2012
    28 Dec 2012
    Link to this post
    Was this ever answered?  The last post was from July 2011.
    Is there any documentation on how to access custom content types in the Fluent or regular APIs?
    Thanks
  6. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    16 Aug 2017
    02 Jan 2013
    Link to this post
    Hi,

    The Q2 release have passed and custom modules can be queried using the native API
    The API of custom modules is like the API for the built in modules, just change the name of the managers you are working with, as they represend the manager classes of the ProductCatalogSample.

    using ProductCatalogSample.Data;
    using ProductCatalogSample.Model;
    using Telerik.Sitefinity.GenericContent.Model;
          
          
    ProductsManager manager = ProductsManager.GetManager();
    //create a query for type ProductItem
                ProductItem item = manager.GetProducts()
                                     .Where(t => t.Title == "Test" && t.Status == ContentLifecycleStatus.Live).Single();
                      item.UrlName = "changedURL";
                    
          manager.SaveChanges();

    Greetings,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
6 posts, 0 answered