More in this section

Forums / Developing with Sitefinity / How to get related content by tags and/or categories?

How to get related content by tags and/or categories?

2 posts, 0 answered
  1. HRC
    HRC avatar
    44 posts
    16 Mar 2009
    29 May 2009
    Link to this post
    Hi there,

    I'm working on a "Related Content" control and for any given page, I wish to pull up a list of links to related pages based on tags. 

    For example, if the page I'm on has been tagged with "hr", the control would pull up other pages tagged with the same tag.

    If the page I'm on has been tagged with "hr" and "policies", pages with *both* tags would rank higher than pages with only one of them.

    Also, is there a way to do this so that no matter what the content actually is (news item, blog post, generic content, ...) it will pull it up?

    Any guidance you can provide would be really appreciated!

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    30 May 2009
    Link to this post
    Hello iStudio,

    The pages cannot be tagged. You can tag the content items. To find the pages where the tagged content items have been located you should loop through all pages, then get the content items that are on the pages and check whether they have been tagged. If so, then response write the url. The better option is getting the control on the page  - for instance NewsView control and then form the url, because the content items will return relative url, not absolute. When you find the control on a page you can get the page url and append the relative url of the tagged content to it.

     IList<ICmsPage> pages = page.GetPagesByControlType(typeof(NewsView)); 

    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