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

Forums / Developing with Sitefinity / Generic Content - customisation

Generic Content - customisation

5 posts, 2 answered
  1. Andree
    Andree avatar
    44 posts
    Registered:
    11 Jan 2010
    02 Feb 2010
    Link to this post
    Hiya,

    I'm preparing a section on our new site that involves a customisation of the existing sitefinity behaviour, to cater for articles that we publish. These articles are fairly straight forward text content, but how much of it they can see depends whether they're signed in or not.

    These articles, on the end-user side of things, need to be searchable by category and keywords too.

    I've had a look over the Generic Content API documentation, and I'm undecided whether or not the existing News module will cater for this (with added end-user custom user controls), or whether I need to write a custom Module for it. A few things that will help me clear this up:

    1. Looking at the "Finding Content Items" documentation ( http://www.sitefinity.com/help/developer-manual/content-items-get.html ), I don't see a way of filtering by category and keyword at the same time, is this possible?

    2. On the end-user side of things, the news module appears to have a virtual path for each news item - is it possible to write custom virtual url handlers for custom user controls, and if so, could you give me a pointer towards documentation for this?

    Regards,
    Alvaro
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    02 Feb 2010
    Link to this post
    Hello Alvaro,

    1. Looking at the "Finding Content Items" documentation ( http://www.sitefinity.com/help/developer-manual/content-items-get.html ), I don't see a way of filtering by category and keyword at the same time, is this possible?


    You can create a multiple filters, but you can filter only by metakey. If the "keywords" are metakeys you should be able to filter without problems. You can use ContentFilterbuilder class  or MetaSearchInfo class.

    2. On the end-user side of things, the news module appears to have a virtual path for each news item - is it possible to write custom virtual url handlers for custom user controls, and if so, could you give me a pointer towards documentation for this?

    The news item url format is rewritten. The format is set in the web.config file, section <cmsEngine defaultProvider="Generic_Content"> . You can control the url format from there instead of using custom handlers. You can get the url for each news content object using UrwWithExtesion property.


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
    Answered
  3. Andree
    Andree avatar
    44 posts
    Registered:
    11 Jan 2010
    02 Feb 2010
    Link to this post
    Hi Ivan,

    Thanks for the prompt response.

    If filtering only works by metakeys, would I be right in assuming its not possible to search the content itself? Do you have any recommendations on how to achieve this, other than writing custom code to store and search content rather than using the Generic Content framework?


    Regards,
    Alvaro
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    02 Feb 2010
    Link to this post
    Hello Alvaro,

    You can use the Search Index, but again you need a custom one that looks for categories and other metakeys, otherwise only the content and title is indexed and added to the search snippet.

    In your custom provider you have to implement GetContenttoIndex method. Sample code is shown below

    public IIndexerInfo[] Telerik.Framework.Search.IIndexingServiceClient.GetContentToIndex()
    {
     
            IList<IContent> newsItemsList;
            var manager = new NewsManager("News");
             ....
                      .....
                     // get all categories and create a list
     
                categoriesList = manager.Content.GetCategoriesTree(manager.Content.GetCategory(SelectedCategoryID));
                catList = new List<string>();
                foreach (ICategory cat in categoriesList)
           {
                    categoryNameList.Add(cat.CategoryName);
             }
     
                filterBuilder.AddFilter(new ContentFilterStatement("Category", filterBuilder.GenerateCommaDelimitedString<string>(categoryNameList), ContentFilter.Condition.In, ContentFilter.JoinType.And));
     
                newsList = manager.Content.GetContent(0, 0, "Publication_Date Dec", filterBuilder.ParseTagFilter, ContentStatus.Published, null, filterBuilder.ParseParentsFilter, filterBuilder.ParseMetaFieldsFilter);
                 
                            // create Indexer info list of content items.
            List<IIndexerInfo> contentItems = new List<IIndexerInfo>();
            foreach (IContent news in newsList) {
                  
                NewsIndexerInfo contentIndexerInfo = new NewsIndexerInfo();
                contentIndexerInfo.ID = news.ID;
                contentIndexerInfo.Title = news.GetMetaData("Name").ToString();
                contentIndexerInfo.Author = news.GetMetaData("Author").ToString();
                contentIndexerInfo.Description = news.GetMetaData("Description").ToString();
                contentIndexerInfo.Extension = news.GetMetaData("Extension").ToString();
                contentIndexerInfo.Category = news.GetMetaData("Category").ToString();
                contentIndexerInfo.Content = news.Content;
                contentIndexerInfo.Url = news.UrlWithExtension;
                contentIndexerInfo.Tags = GetTags(manager.Content.GetTags(news.Content.ID));
     
                contentItems.Add(contentIndexerInfo);
            }
              
            return contentItems.ToArray();
        }
     
    }

    You can take a look at our sample products module which has implemented custom search index.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
    Answered
  5. Andree
    Andree avatar
    44 posts
    Registered:
    11 Jan 2010
    02 Feb 2010
    Link to this post
    Many thanks Ivan.

    Regards,
    Alvaro
Register for webinar
5 posts, 2 answered