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

Forums / Developing with Sitefinity / Is There a CmsManager.GetPageByDefaultUrl?

Is There a CmsManager.GetPageByDefaultUrl?

5 posts, 2 answered
  1. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    11 Jun 2010
    Link to this post
    Good Afternoon,

    I can get a page by additional URLs through CmsManager.GetPageByAdditionalUrl() but there doesn't seem to be a way to find a page by its DefaultUrl.

    I'd like to know whether a URL exists in the system before I try to create a page. If the URL already exists, I'd like to get an ICmsPage object for it.

    GetPageByAdditionalUrl works perfectly for that: I get null if the page doesn't exist or the page object if it does. Unfortunately, it doesn't seem to include Default Urls in its search. Therefore I cannot guarantee a URL is unique.

    Is there a way to search for a page by its Default URL?

    Thanks,
    Jeff
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    14 Jun 2010
    Link to this post
    Hi Jeff,

    You can take the page by using the sitemap provider - 

    // Sitefinity is using standard ASP.NET SiteMap provider. Therefore,
    // Sitefinity pages can be accessed just as any ASP.NET website using
    // SiteMap provider. It is important to note that SiteMapNode should be
    // case to Telerik.Cms.Web.CmsSiteMapNode, which is our own improved version
    // of SiteMapNode object which provides a very handy CmsPage property - a reference
    // to the ICmsPage object associated with the particular node
    Telerik.Cms.Web.CmsSiteMapNode siteNode = (Telerik.Cms.Web.CmsSiteMapNode)SiteMap.Provider.CurrentNode;
    foreach (Telerik.Cms.Web.CmsSiteMapNode childNode in siteNode.ChildNodes)
    {
     Response.Write(childNode.CmsPage.MenuName);
    }

    The only thing that you should do though, is to pass the node that you want, rather than the current node. 

    I hope this helps. 

    All the best,
    Georgi
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  3. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    14 Jun 2010
    Link to this post
    Thanks Georgi. That should work just fine.

    Jeff
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Jun 2010
    Link to this post
    Hello Jeff,

    Another option has been provided here -get page by url

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  5. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    14 Jun 2010
    Link to this post
    That looks like an even better solution since you don't have to walk the entire Site Map.

    Thanks,
    Jeff
Register for webinar
5 posts, 2 answered