23 Mar 2010
22 Apr 2010
Link to this post
1. I'm creating a custom control to show news items (we call them Articles!). I need to filter the list in my custom control (essentially a repeater showing news items) by Category AND multiple tags. I have read that filtering by multiple tags is coming in 4.0, but we need it now :o/
I have successfully got a list of news items back to match the category entered in a public property, and 1 tag.
NewsManager newsManager = new NewsManager("News");
//Get list of news items with the stated category and content area (menu area)
List<IMetaSearchInfo> filter = new List<IMetaSearchInfo>();
filter.Add(new MetaSearchInfo(MetaValueTypes.ShortText, "Category", _category, SearchCondition.Equal, JoinType.And));
IList newsList = newsManager.Content.GetContent(0, _maxArticles, "Publication_Date DESC", _contentArea, null, string.Empty, null, filter.ToArray());
(where _category and _contentarea are public properties on my control - therefore editable on the edit page of the control. _contentarea is just another tag nothing special but just makes it more intuitive on the interface). I have another public property of 'tags' where we will type a list of comma seperated tags then I get them in my code behind using string.split )
i now need to filter the list further by 1 or many more tags. I really dont want to loop through my tags and for each extra tags filter the list further. Very inefficient since it will do a round trip every time. Either way I dont know how to filter an already filtered list (i.e. filter my IList, newsList)
Or can I just use SQL to access my content? since I can just write a sql query to get the items I want. I know it is bypassing sitefinity logic, but im scratching my head a little bit where normally i'd have written a sql statement to get content items by multiple tags, and done this task in half an hour.
2. This is a less urgent question: but can I rename EVERY occurrence of 'news' to 'articles' in the system. We have articles, and news are types of articles, and the sitefinity dashboard will most definately confuse our users!! :o/
Any help or ideas greatly appreciated.