More in this section

Forums / Developing with Sitefinity / Get items from names instead of GUID?

Get items from names instead of GUID?

2 posts, 1 answered
  1. Magnus
    Magnus avatar
    28 posts
    26 May 2009
    03 Dec 2009
    Link to this post
    Hey there.

    I've been searching for some mins now but couldnt find any useful information (which i was kinda surprised of, cause i think it's more then me that having this problem).

    I've been working kinda much now with Sitefinity in several projects. But i'm afraid i havent got the "GUID" under control.

    In almost every module/control which i'm editing from code-behind i need to get a specific item using that item's GUID. But if i dont know which GUID that certain item have (take Forum Category as an example) what shall i do then?
    After reading this forum category api content all i found out was how to receive the GUID from the first Category. But if i have like 500 categories.. Do i need to loop all the items and check for that certain category (by name)? 
    Been having the same problem for Pages, Forum, Blogs etc.

    So.. to my question. Is there anyway to receive the GUID from example a Forum Category without using a loop?
    Example:      Telerik.Forums.ICategory forumCat = forumManager.GetCategoryByName("categoryname");

    I've been having some troubles with this in several other scenarios.. But have always found a way round this problem.
    Example fpr pages:
                Telerik.Cms.Web.CmsSiteMapNode gruppen = (Telerik.Cms.Web.CmsSiteMapNode)SiteMap.Provider.FindSiteMapNode("~/grupper.aspx"); 
                Telerik.Cms.IPage tmppage = cmsManager.GetChildPageByName(gruppen.CmsPage.ID, "template"); 
                Telerik.Cms.IPage p1 = cmsManager.GetPage(tmppage.ID); 

    But now i'm kinda stuck.

    Any help here would be welcome in how to receive that GUID in other ways.

    Kind Regards / Magnus.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    03 Dec 2009
    Link to this post
    Hello Magnus,

    There is no method implemented for getting categories by name. You have to loop through the items first.

    var fMgr = new ForumManager();
    IList allcat = fMgr.GetCategories();
    foreach (Telerik.Forums.ICategory cat in allcat)
        if (cat.Name == "somename")

    The same applies for pages, but I see that you have found a solution.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 1 answered