More in this section

Forums / Developing with Sitefinity / Searching for content / pages

Searching for content / pages

6 posts, 0 answered
  1. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    31 Mar 2008
    Link to this post
    Hi Guys,

    Can you please help me find what namespaces and / or objects in your api's so that I can programmatically search for pages.

    In Microsoft's MCMS you can search for content based on a a url, path, and guid etc to get channels and postings. Can your sitefinity do this? If so how?

    You have a CmsManager object, but this only allows to search for pages based on a guid.

    We need more information on how we can inspect the data inside a sitefinity application.

    Thanks,

  2. Sonya
    Sonya avatar
    231 posts
    Registered:
    24 Sep 2012
    02 Apr 2008
    Link to this post
    Hello sam,

    Please take a look at the Sitefinity API Reference in the Developer Manual, the CmsManager Class Members. You  could see that the GetPages method returns a list of all pages - you could make use of that.

    Apart from that,take a look at the following code. It gets information about the current page:

    using System;  
    using System.Collections;  
    using System.Configuration;  
    using System.Data;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.HtmlControls;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using Telerik.Cms;  
    using Telerik.Cms.Engine;  
    using Telerik.Cms.Web;  
      
    public partial class MyControls_Pages : System.Web.UI.UserControl  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            ICmsUrlContext urlContext = CmsUrlContext.Current;  
            if (urlContext == null)  
                return;  
      
            CmsManager manager = new CmsManager();  
            ICmsPage cmsPage = manager.GetPage(urlContext.PageID) as ICmsPage;  
            if (cmsPage != null)  
            {  
                string s;  
      
                Guid id = urlContext.PageID;  
                //s = cmsPage.Name;  
                //s = cmsPage.Title;  
                //s = cmsPage.MenuName;  
                //s = cmsPage.PageType.ToString();  
                //s = cmsPage.Owner;  
                //IList subPages = cmsPage.Pages();  
                //s = cmsPage.ParentID;                        
            }  
        }  
    }  


    You could find all available methods in the Manager class of a module. Managers also handle providers, so you need not worry about that as well. When working with content, see the ContentManager Class Members which is used for all modules based on Generic Content. When working with Lists or Forums, see the Lists Manager or the Forums Manager.

    As to your question on searching for content: you could use any of the overloads of the GetContent method and make queries based on meta fields. So, here is an example code that searches for content based on categories:

    MetaSearchInfo metaInfo = new MetaSearchInfo(MetaValueTypes.ShortText, "Category""Your_Category_Name", SearchCondition.Like, JoinType.And); 
    ContentManager mangr = new ContentManager(); 
     
    mangr.GetContent(0, 20, "", ContentStatus.Published, metaInfo); 


    Also, you could search for content by the other meta fields described in the web.config file: <cmsEngine> tag -> <metaFields> tag. For example, for the Generic Content module there are the following meta fields:
    • Generic_Content.Name
    • Generic_Content.Description
    • Generic_Content.Author
    • Generic_Content.Category
    In the database, the table sf_GCMetaData holds all meta information based on ContentId. Thus, you could search for:
    • LangID
    • KeyValue
    • Application
    • ValueType
    • ShortText
    • LongText
    • DateTimeValue
    • IntegerValue
    • Boolean
    • CntPrntID
    and more...

    The CntPrntID field is the ID of the parent of the current content item - this is available only for Blogs and Libraries (where the corresponding parents for a given content would be a Blog or a Library). Thus, you could search for content based on a Blog or Library.

    Another database table that might be useful when searching for content is sf_CmsContentVersion where content could be searched based on ID of the parent.

    The ContentID field in the sf_GCMetaData relates a row in the table to a record in the sf_CmsContentVersion table. This means you could use its fields to create even more complicated search queries.

    Hope this is helpful. Please let us know if you need further assistance on the matter.

    Greetings,
    Sonya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    02 Apr 2008
    Link to this post
    Thanks for the answer to this.

    The problem we are finding is there is no documentation in the API. Is this going to change? And when

    Example  

    GetByTemplate, GetByURL. GetByPath what do these do? And do you have short examples?

  4. Sonya
    Sonya avatar
    231 posts
    Registered:
    24 Sep 2012
    04 Apr 2008
    Link to this post
    Hi sam,

    This is definitely going to change. Providing explanation in the API Reference is going to be one of the main goals for the next major release. Please excuse us for the time you have to spend working with this reference in its current state. Let us know of any problems or questions you have in the process.


    Sincerely yours,
    Sonya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Kevin
    Kevin avatar
    42 posts
    Registered:
    15 Mar 2005
    15 Apr 2008
    Link to this post
    Sonya (et al):

    It really would be great to see a bit better documentation, particularly clearer descriptions and code examples.  I really like Sitefinity, but I'm pulling my hair out to do things that should be very simple, only because it is so difficult to find examples.  I spent at least an hour tonight to learn how to search for all items based on GenericContent having a certain Category.  That's pretty straight-forward to me, but it was a lot harder to find that I thought, and I I had to dig a lot deeper than normal to find out where <metaFields< come from, etc.

    As a developer, I understand that documentation sometimes gets a lower priority, but I suspect as Sitefinity matures, the lack of good documentation will be something that prevents people from adopting your product.

    On a positive note, my experience with Telerik's technical support has always been very positive (which is why I've renewed my Telerik components subscription three years in a row), and in the end it was because of the excellent and thorough answer in this post that I figured out how to do what I wanted.  Thanks for that, but it would be nice if these kinds of articles could make their way into the documentation, including a list of, say, 10 common development scenarios, etc.

    Thanks for your effort in any case, and I appreciate your great products (well documented or not :-),
    Kevin Townsend
  6. Sonya
    Sonya avatar
    231 posts
    Registered:
    24 Sep 2012
    18 Apr 2008
    Link to this post
    Hello KEVIN TOWNSEND,

    Thank you for your feedback. We do realize the developer documentation is our weakest point. That is why we have planned a major update of the documentation on which we will start working after the release of Service Pack 2.

    Thank you for your patience and understanding.

    Kind regards,
    Sonya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
6 posts, 0 answered