Copied to clipboard

Flag this post as spam?

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


  • Michael Nielsen 99 posts 619 karma points
    Oct 14, 2014 @ 14:39
    Michael Nielsen
    0

    Flat URL structure

    This seems like a simple question, but I've looked through the other posts and haven't really found a defnite answer.

    Usually the structure and URLs of a site is like this:

    - Content
    - Home (url= /)
    - About Us (url= /about-us)
    - Products (url= /products)
    - SingleProduct (url= /products/singleproduct)
    - Contact (url= /contact)

     

    But would it possible to do this

    - Content
    - Home (url= /)
    - About Us (url= /about-us)
    - Products (url= /products)
    - SingleProduct (url= /singleproduct)
    - Contact (url= /contact)

    The change is that all URLs is under the root node. 

  • Dan Lister 416 posts 1973 karma points c-trib
    Oct 14, 2014 @ 15:48
    Dan Lister
    0

    I think you could use the 'umbracoUrlAlias' property to provide an additional url for each page. Take a look at this documentation page for more information. You could also create an event to set the property when the product page is saved.

    Thanks, Dan.

  • Michael Nielsen 99 posts 619 karma points
    Oct 14, 2014 @ 15:58
    Michael Nielsen
    0

    Hi Dan

    But multiple URLs to the same content would result in duplicate content.

  • Dan Lister 416 posts 1973 karma points c-trib
    Oct 14, 2014 @ 16:01
    Dan Lister
    0

    True but you could create a SurfaceController for your Document Type to check which URL a visitor is using. If using the default URL, you could redirect the visitor to the umbracoUrlAlias version. Its a bit hacky but it would allow you to have the URL structure you'd require.

    Thanks, Dan.

  • Michael Nielsen 99 posts 619 karma points
    Oct 14, 2014 @ 16:09
    Michael Nielsen
    0

    "Unnecessary" redirects are not an option as the client is very SEO capaple and minded and would point that out immediately. :-/

  • Dan Lister 416 posts 1973 karma points c-trib
    Oct 14, 2014 @ 16:12
    Dan Lister
    0

    You could always throw a 404 exception instead of a redirect. That should solve your duplicate content problem and not wanting unnecessary redirects.

    Thanks, Dan.

  • [email protected] 378 posts 1915 karma points MVP 4x c-trib
    Oct 14, 2014 @ 16:16
    jeffrey@umarketingsuite.com
    0

    Hi Ørskov,

    another way of achieving this is using the power of UrlProviders (http://www.zpqrtbnk.net/TheUmbraco6RequestPipeline.pdf).

    If you implement the interface IUrlProvider in this way:

    public class YourUrlProvider : IUrlProvider
        {
            public IEnumerable<string> GetOtherUrls(Umbraco.Web.UmbracoContext umbracoContext, int id, Uri current)
            {
                return Enumerable.Empty<string>();
            }

            /// <summary>
            /// Implements a better version of getURL;
            /// </summary>
            /// <param name="umbracoContext"></param>
            /// <param name="id"></param>
            /// <param name="current"></param>
            /// <param name="mode"></param>
            /// <returns></returns>
            public string GetUrl(Umbraco.Web.UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
            {
                var node = umbracoContext.ContentCache.GetById(id);
                if (node != null && node.Parent != null)
                {
                    if (node.DocumentTypeAlias == "YourSingleProductDocType")
                        return umbraco.cms.helpers.url.FormatUrl(node.Name) + "/";
                }

                return null;
            }
        }

    And you add the URLProvider like this

    public class OnStartUp : IApplicationEventHandler
        {
            public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {

            }

            public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {

            }

            public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                UrlProviderResolver.Current.InsertType<YourUrlProvider>();
            }
        }

    In that way Umbraco will do all the hard stuff for you.

    Hope it helps,

    Jeffrey

  • Michael Nielsen 99 posts 619 karma points
    Oct 15, 2014 @ 08:26
    Michael Nielsen
    0

    Well I was hoping for configuration type solution. I'm not a .Net developer, so VS, compiling and so on is really not something I want to get into. I feel that it should be possible to have full control over the url, without having to resort to .Net development.

    But I guess I'll solve it by having a folder with all the pages, and then build my menu with shortcut doctypes, pointing to those pages. 

  • [email protected] 378 posts 1915 karma points MVP 4x c-trib
    Oct 15, 2014 @ 09:04
    jeffrey@umarketingsuite.com
    1

    Aah, I see. In that case creating a "Textstring" - property with the alias "umbracoUrlAlias" is the best way. In newer versions of Umbraco the url will completely be replaced instead of creating two url's (the documentation is a bit old).

    Good luck!

     

  • 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