More in this section

Forums / Developing with Sitefinity / Filter News by a public Control based on metafields

Filter News by a public Control based on metafields

15 posts, 0 answered
  1. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    14 May 2008
    Link to this post
    Hi,

    Could you help-me to build one Usercontrol to filter in public side the News to add in ListNews based on filtering or selected Metafields.

    How to create a multi select like selected "author" & OR "my1-metafields" NotEqual "my2-metafields".

    Could extend this solution to select tags and categories?. 

    like   Tags &/or Categories & Author & my1-metafields  
                        --> Selected News in NewsList

    Thanks, Regards 
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    17 May 2008
    Link to this post
    Hello Pierre,

    Have you tried the NewsManager and GetContent() method? For example, you can get all news items with GetContent() method, then perform special filtering based on your criteria. I noticed that you want to perform something like special queries. I may also suggest you migrate your project to .NET3.5 and use LINQ on the list with the news items.
    We would be glad to assist you with any difficulty you experience while developing your control.

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    17 May 2008
    Link to this post

    HI Georgi,

    Could you help-us to build this usercontrols that filter News based on metafields dropdowns and Extending NewsList to inherit this filter. Adding this in one same webpage you can filter the news on screen in public side. No filter, all news, filtering news only selected. It's possible?

    Regards

  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    20 May 2008
    Link to this post
    Hello Pierre,

    We suggest you wait for SP2 where we'll introduce a new News control. It will be easily customizable and based on ContentView, so probably it will work fine for your needs.

    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    20 May 2008
    Link to this post
    Hi,
     
    Many thanks for your work. I searching solution not based in Edit Basic/advanced Mode during creation/mod page, I search  filter the news in the online website directly in the page based on usercontrol that modify filter and ListNews in same page that inherit them like search news (but filter news). Would be possible to make in 32sp2 more easier?. Any help is wonderfull. Regards
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    23 May 2008
    Link to this post
    Hello Pierre,

    We are focused on SP2 development and the control already mentioned. The custom control you want will take us too much time to be developed. Our opinion is that it would be good if you could see if the new control would fit your needs. Later you could simply extend it. This will save some work on creating new control on the scratch.

    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. nogatek
    nogatek avatar
    35 posts
    Registered:
    23 Apr 2008
    06 Aug 2008
    Link to this post
    Hi Georgi,

    Do you some example code on how to work with the NewsManager class?

    (either in master page code behind and / or the NewsView control)

    I would like to perform some simple news category counts for displaying to users.

    Thanks heaps, Mark
  8. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    07 Aug 2008
    Link to this post
    Hi Mark,

    you can find more information and examples on NewsManager class in our Developers manual:
    http://www.sitefinity.com/help/developer-manual/news-api-overview.html

    You will find dozens of examples on how to work with News module API.

    I hope you'll find this information helpful. Let us know if there is anything else we can do for you.

    Greetings,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. nogatek
    nogatek avatar
    35 posts
    Registered:
    23 Apr 2008
    07 Aug 2008
    Link to this post
    Thanks Ivan!

    Yes, working with the NewsManager class and all is well.

    However, I have ran into another problem. I have written a script that iterates all news items and this works fine. But when I try to update the actual Content field of the news items, I get a database error.

    I can update the MetaData fields okay - but not the actual Content field of items.

    Using the example code snippet below that adds a new record, how could I change this to update the Content field of an existing record?

    Thanks, Mark


    // create new instance of NewsManager
    Telerik.News.NewsManager newsManager = new Telerik.News.NewsManager("News");
    // create a news content item by calling the CreateContent method of the
    // ContentManager class through the NewsManager class
    Telerik.Cms.Engine.IContent newsContent = newsManager.Content.CreateContent("text/html");
    // save the Content property value, and the Title meta key
    newsContent.Content = "My first News Item";
    newsContent.SetMetaData(
    "Title", "News 1");
    //save the Content item through the NewsManager
    newsManager.Content.SaveContent(newsContent);
    Response.Write(newsContent.Content +
    "<br />");


  10. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    08 Aug 2008
    Link to this post
    Hello Mark,

    Unfortunately, you have forgotten to tell me what error do you get. However, I am assuming you are getting something like "object not associated with transaction".

    I've just checked the documentation and I see that we have not made this clear enough, so it's on our to do list for the next update.

    Anyhow, in order to update the content (in your case news item) you need to use GetContent(Guid id) method, which will return an IContent item associated with the transaction. So for example, if you want to update all the news on your site, you would have a code looking something like this:

    NewsManager newsManager = new NewsManager("News");  
    IList allNews = newsManager.Content.GetContent();  
    foreach(IContent news in allNews)  
    {  
        // notice how we are getting the IContent object again here, because we need  
        // one associated with transaction  
        IContent newsInTransaction = newsManager.Content(news.ID);  
        newsInTransaction.Content = "- UPDATED -";  
        newsManager.Content.SaveContent(newsInTransaction);  

    I know that this may seem a bit redundant, but it improves performance when doing just querying. Anyhow, for Sitefinity 4.0 we are preparing a new advanced Generic Content API that will simplify working with the API, but perhaps even more importantly it will perform much better. The new advanced API will be completely backward compatible with the current one.

    I hope you'll find this information helpful. Let us know if there is anything else we can do for you.

    Greetings,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  11. nogatek
    nogatek avatar
    35 posts
    Registered:
    23 Apr 2008
    09 Aug 2008
    Link to this post
    Thanks Ivan!

    Fantastic. That will be a very handy script to use whenever we need to perform any global content updates.

    Cheers, Mark
  12. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    10 Aug 2008
    Link to this post
    Hi Mark,

    glad to be able to help.

    Let us know if there is anything else we can do for you.

    Best wishes,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  13. Frederico Fernandes
    Frederico Fernandes avatar
    29 posts
    Registered:
    27 Oct 2009
    03 Dec 2009
    Link to this post
    Hi Ivan,

    Can you explain how do you update the content of news? I see the exmple but this line doesn't work.
    any ideia? 

    IContent newsInTransaction = newsManager.Content(news.ID);
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    03 Dec 2009
    Link to this post
    Hello Frederico Fernandes,

    Give a try to this:

    IContent newsInTransaction = newsManager.Content.GetContent(news.ID);

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  15. Frederico Fernandes
    Frederico Fernandes avatar
    29 posts
    Registered:
    27 Oct 2009
    03 Dec 2009
    Link to this post
    Hi Ivan it works thanks. :)
Register for webinar
15 posts, 0 answered