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

Content Items

4 posts, 0 answered
  1. Sang
    Sang avatar
    13 posts
    Registered:
    14 May 2008
    19 Aug 2008
    Link to this post
    What is the best way to retrieve a content item through the API based on what category the content item is under and if it has a specific tag?

    My scenario is where I will have several categories and in each category there will be a certain content item that will have a certain tag that I can use to identify the item that I want from that category.

    Thanks in advance,

    Sang
  2. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    20 Aug 2008
    Link to this post
    Hi Sang,

    You can find more information about finding content items from our Generic Content API walkthrough:
    http://www.sitefinity.com/help/developer-manual/content-items-get.html

    For your particular scenario I would suggest using this method:
    http://www.sitefinity.com/help/developer-manual/content-items-get.html#GetContent_by_from_max_sortExp_tagName

    It will return the list of content items, but if you are excepting that only one item is going to be retrieved you can simply take the first item from the list and cast it to IContent interface.

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

    Sincerely yours,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Sang
    Sang avatar
    13 posts
    Registered:
    14 May 2008
    20 Aug 2008
    Link to this post
    Hi Ivan,

    I don't think that will be the best solution for me.  Let me clarify my scenario because if I used the method you recommended, it won't necessarily work.

    Example:

    Category 1:
        Content Item 1 - Tag Blue
        Content Item 2 - Tag Green
    Category 2
        Content Item 1 - Tag Blue
        Content Item 2 - Tag Green
    Category(n)
        Content Item (n) - Tag Blue
        Content Item (n) - Tag Green

    The situation is I want grab a item tag blue, but I want the one that belongs to Category 2.  I hope this makes more sense.  What would be the best solution to use? I look through the Developer's guide and don't see a method that can get the result that I want.  I can go grab all the items tag blue, but can't seem to find a way to go see which category it belongs too.

    Thanks,

    Sang
  4. Sang
    Sang avatar
    13 posts
    Registered:
    14 May 2008
    20 Aug 2008
    Link to this post
    Hi Ivan,

    I missed it in the developers guide, so the solution is to go through the IContent interface and used the GetMetaData method to pull back the category.  Thanks for all you help.

    Sang
Register for webinar
4 posts, 0 answered