Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • NgHello 3 posts 71 karma points
    Sep 07, 2017 @ 08:53
    NgHello
    0

    Cannot change home url

    Hello,

    I'm trying to mirror the site structure setup as shown in the Umbraco hybrid framework project

    https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises

    I realise this is outdated now, but I only want to mimic the structure, namely having a Root "Website" node and beneath it my 'visible' nodes, such as home, contact etc.

    The steps I have followed have been;

    • Created a bootstrapper class which implements IApplicationEventHandler

    • Within the OnApplicationStarting method I've included a HomeUrlProvider, like so : UrlProviderResolver.Current.InsertTypeBefore<DefaultUrlProvider, HomeUrlProvider>();

    • The home urlprovider which gets called looks pretty much exactly as it does within the hybrid framework project. My get url method is as follows;

      public string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
      {
          var content = umbracoContext.ContentCache.GetById(id);
          if (content != null && content.DocumentTypeAlias.ToLower() == "home" && content.Parent != null)
          {
              //The home node will have / instead of /home/.
              return content.Parent.Url;
          }
          return null;
      }
      

    I have set a property on the 'website node' to redirect any navigation from the website node to the home node. This property is set on the node as UmbracoInternalRedirectId and using a picker, the home node is selected.

    On debugging, when in the umbraco back office, if I select the home node the GetUrl method is called and returns '/' as expected.

    When I look at the back office, to check the url for the home node under properties, it shows this message;

     This document is published but its url would collide with content /Website (id=1083)
    

    I am quite confused, because as far as I can tell I've mirrored the hybrid framework method - which when I debug behaves much the same as my solution. I'm totally lost - any help? Thanks.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies