More in this section

Forums / Developing with Sitefinity / SF 3.7 to SF 5.0 Code Conversion

SF 3.7 to SF 5.0 Code Conversion

2 posts, 0 answered
  1. Byzza
    Byzza avatar
    89 posts
    Registered:
    09 Jul 2007
    08 Mar 2012
    Link to this post
    Hi I was just wondering if someone could point me in the write direction to help me convert these 2 short blocks of code from 3.7 to 5.0
    thank you in advance.
    1)
    try
    {
    Telerik.Cms.CmsManager cmsManager = new Telerik.Cms.CmsManager();
    // get the current node of sitemap
    Telerik.Cms.Web.CmsSiteMapNode currentNode = (Telerik.Cms.Web.CmsSiteMapNode)SiteMap.CurrentNode;
    // get the CmsPage represented by the current node and extract its ID
    Telerik.Cms.ICmsPage currentPage = currentNode.CmsPage;
    Guid currentPageId = currentPage.ID;
    hlink.NavigateUrl = "~/loadpages.aspx?guid=" + currentPageId.ToString();
    hLinkWhole.NavigateUrl = "~/loadpages.aspx?guid=" + ParentPageGUID; // currentPageId.ToString();
    //Telerik.Cms.Web.CmsSiteMapNode siteNode = (Telerik.Cms.Web.CmsSiteMapNode)SiteMap.Provider.CurrentNode;
     
    //Response.Write(siteNode.RootNode.Title + ": " +siteNode.ParentNode.Title + ":" + siteNode.Title);
    }
    catch (Exception ex)
    {
    }


    2)
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
        Telerik.Cms.CmsManager cmsManager = new Telerik.Cms.CmsManager();
        // get the current node of sitemap
        Telerik.Cms.Web.CmsSiteMapNode currentNode = (Telerik.Cms.Web.CmsSiteMapNode)SiteMap.CurrentNode;
        // get the CmsPage represented by the current node and extract its ID
        Telerik.Cms.ICmsPage currentPage = currentNode.CmsPage;
        Rev.Text += currentPage.Version.ToString();
        lbUpdated.Text += currentPage.DateModified.ToShortDateString();
        }
        catch (Exception ex)
        {
        }
    }


    Thank you
    Byron

  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Oct 2017
    13 Mar 2012
    Link to this post
    Hello,

    Generally the only thing you'll need to convert the below code would be getting the current PageSiteNode, please correct me if the desired use case scenario is different. You can achieve this functionality by using SiteMapBase like this:
    var currentNode = SiteMapBase.GetActualCurrentNode();
    var currentNodeId = currentNode.Id;

    Kind regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered