Equivalent of CmsUrlContext?

Posted by Community Admin on 04-Aug-2018 13:40

Equivalent of CmsUrlContext?

All Replies

Posted by Community Admin on 20-Apr-2012 00:00

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[quote];

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


Any help, tips, pointers or straight up code gratefully recieved!

Posted by Community Admin on 18-Oct-2012 00:00

Hi Richard

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

Thanks
Yosief

Posted by Community Admin on 19-Oct-2012 00:00

Anyone? Telerik guys??

This thread is closed