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

Forums / Bugs & Issues / Equivalent of CmsUrlContext?

Equivalent of CmsUrlContext?

3 posts, 0 answered
  1. Richard
    Richard avatar
    49 posts
    Registered:
    13 Jul 2010
    20 Apr 2012
    Link to this post
    Me again!

    So migrating from 3.7 to 5 is FUN!

    Anyway, I have the following bit of code in my legacy Sitefinity site and I cannot for the life of me work out what the 'new' equivalent would be. I have tried various different methods but I end up bringing in the old CMS references, something I want to avoid given they are effectively now redundant/no longer support or developed against:

     
    public void RadPanelbar1_ItemDataBound(object sender, RadPanelBarEventArgs e)
      {
          if (this.hideUrlForGroupPages)
          {
              CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;
              if (node != null && node.CmsPage.PageType == CmsPageType.Group)
              {
                  e.Item.NavigateUrl = "";
              }
          }
          if (CmsUrlContext.Current != null)
          {
              if (CmsUrlContext.Current.Path == Page.ResolveUrl(e.Item.NavigateUrl).ToLower())
                  e.Item.Selected = true;
          }
     }

     protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                ICmsUrlContext urlContext = CmsUrlContext.Current;
                if (urlContext != null)
                {
                    if (urlContext.Parent != null)
                        urlContext = urlContext.Parent;
                    SiteMapDataSource1.StartingNodeUrl = urlContext.Path;
                    SiteMapDataSource1.ShowStartingNode = true;
                }
            }
        }

    Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager();
            List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>();
            filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Category", "Customer Quotes"));
            IList listOfContentItems = contentManager.GetContent(filter.ToArray());

            if (listOfContentItems.Count > 0)
            {
                int quotes = listOfContentItems.Count;
                Random rnd = new Random(DateTime.Now.Second);
                int quote = rnd.Next(0, quotes);

                IContent contentItem = (IContent)listOfContentItems
    ;

                CustQuoteHeader.InnerText = contentItem.GetMetaData("Name").ToString();
                CustQuoteContent.InnerText = contentItem.Content.ToString();
            }


    Any help, tips, pointers or straight up code gratefully recieved!
  2. Yosief
    Yosief avatar
    27 posts
    Registered:
    20 Mar 2008
    18 Oct 2012 in reply to Richard
    Link to this post
    Hi Richard

    Did you finally figure out what the equivalent is? I'm facing the same challenge as yours

    Thanks
    Yosief
  3. Yosief
    Yosief avatar
    27 posts
    Registered:
    20 Mar 2008
    19 Oct 2012 in reply to Yosief
    Link to this post
    Anyone? Telerik guys??
3 posts, 0 answered