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

Forums / Developing with Sitefinity / Get URL of a page

Get URL of a page

11 posts, 0 answered
  1. Court
    Court avatar
    20 posts
    Registered:
    24 Nov 2009
    25 Jan 2010
    Link to this post

    I’m looking at the Sitefinity API to get a page id by file name and I’m not see anyway to do so. I did see an example of how to do it if I am currently on that page.  What I need from the API is the URL to the page I that I want to go to next.

     

    So if I am currently on Page “abcd.aspx” which has a custom control form. On the postback and after processing that form I will need  to go to page “defg.aspx” as my Response.Redirect. But I need to find out the URL of that page before I can redirect.  


    I am assuming I first need to get that pageId and then I can use Telerik.Cms.IPage pageFromDb = cmsManager.GetPage(currentPageId) to get the page info that I need. But I’m am unsure on how to get the pageId based on just the file name without having to write my own linq to talk to the database.

     

    Help?!?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Jan 2010
    Link to this post
    Hi Court,

    Below are two samples

    1. Get the page by url

    var cmsManager = new Telerik.Cms.CmsManager();
    Telerik.Cms.Web.CmsSiteMapNode node = (Telerik.Cms.Web.CmsSiteMapNode)SiteMap.Provider.FindSiteMapNode("~/SamplePage.aspx");
    Telerik.Cms.ICmsPage cmsPageObj = cmsManager.GetPage(node.CmsPage.ID, true) as Telerik.Cms.ICmsPage;

    2. Get the page url by using ICmsPage object.

    var manager = new CmsManager();
    ICmsPage page = (ICmsPage)manager.GetPage(GuidId);
    string url = page.StaticUrl;


    Greetings,
    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.
  3. Court
    Court avatar
    20 posts
    Registered:
    24 Nov 2009
    25 Jan 2010
    Link to this post
    Getting the SiteMapNode of the requested file is returning a null.

    What am I missing or doing wrong?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Jan 2010
    Link to this post
    Hello Court,

    Most probably you are passing not the correct node in FindSiteMapNode

    Kind regards,
    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.
  5. Court
    Court avatar
    20 posts
    Registered:
    24 Nov 2009
    25 Jan 2010
    Link to this post
    I'm referencing a page that is in the Sitefinity CMS. Its not an actual physical flat file.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Jan 2010
    Link to this post
    Hello Court,

    There is a cast to CmsSiteMapNode and ICmsPage , so you get the ICmsPage object created by Sitefinity.

    Regards,
    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.
  7. Court
    Court avatar
    20 posts
    Registered:
    24 Nov 2009
    26 Jan 2010
    Link to this post
    So I'm getting a null for 'cmsPageObj' when doing this:

    Telerik.Cms.

    ICmsPage cmsPageObj = manager.GetPage(pageBase.ID, true) as Telerik.Cms.ICmsPage;
    The 'pageBase' is not null and the 'pageBase.ID' does have a Guid.

    And if I do this...
    ICmsPage page = (ICmsPage)manager.GetPage(pageBase.ID);
    An execption is thrown: Unable to cast object of type 'Telerik.Cms.Data.PageTemplate' to type 'Telerik.Cms.ICmsPage'.

    Now if I do this...
    Telerik.Cms.IPage page = manager.GetPage(pageBase.ID);
    GetPage does return data. 'page' is not null. But its not in the ICmsPage type that I need.

  8. Court
    Court avatar
    20 posts
    Registered:
    24 Nov 2009
    26 Jan 2010
    Link to this post
    And I'm still having problems with this...

    Telerik.Cms.Web.CmsSiteMapNode node = (Telerik.Cms.Web.CmsSiteMapNode SiteMap.Provider.FindSiteMapNode("~/SamplePage.aspx");

    'FindSiteMapNode' returns a null.
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 Jan 2010
    Link to this post
    Hi Court,

    Please take a look at the API reference - Pages API Overview. Observe the samples here Sitefinity API Tips & Tricks. Watch this webinar.

    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.
  10. Roopesh
    Roopesh avatar
    39 posts
    Registered:
    29 Oct 2010
    22 Nov 2010
    Link to this post

    Can you give me one example for this ..?
    GetPages(Int32,Int32,String,ListSortDirection,Int32,Boolean)

    i don't know how to pass values to it

    Thank you
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Nov 2010
    Link to this post
    Hi Roopesh,

    Here is a sample that illustrate how to use this overload.

    manager.GetPages(0, 100, "DateModified", ListSortDirection.Descending, out totalCount);


    Sincerely yours,
    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
Register for webinar
11 posts, 0 answered