Copied to clipboard

Flag this post as spam?

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

  • Remi Martel 32 posts 103 karma points
    Apr 16, 2018 @ 18:29
    Remi Martel

    I have the following structure:

    enter image description here

    Photo Collage is a page with radio buttons to select one of the products (4x4, 5x5...).

    When I click my submit button, I need to go to 'Theme' page which is a direct child of Photo Collage (not in the photo), but the URL needs to change depending on the product selected (the selection influences the content of the Theme page).

    This way, I don't have to duplicate the theme page for each product, but the Theme page is bookmarkable with the selected product.

    My problem is that after messing for a while with the Umbraco pipeline and reading a lot of posts. I can't figure out how to change the URL. Even though I am sure the URL returned by the IUrlProvider is unique I still get an error on the back end.

    public string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
            //throw new NotImplementedException();
            // Take curent content item from cache by its id
            var content = umbracoContext.ContentCache.GetById(id);
            // Check if the content exists and it has alias companyItem
            if (content != null && (content.DocumentTypeAlias == "product"))
                if (content.Parent.DocumentTypeAlias == "productGroup" && content.Parent.Parent.DocumentTypeAlias == "productDetail")
                    bool hasThemeAfter = false;
                    foreach (var child in content.Parent.Parent.Children)
                        if (child.DocumentTypeAlias == "themes" && child.Children.Count() <= 0)
                            hasThemeAfter = true;
                    if (hasThemeAfter)
                        // Build path
                        string route = content.Parent.Url + "Themes/" + content.Name + "/";
                        //var domainUri = new Uri(current.GetLeftPart(UriPartial.Authority));
                        //return AssembleUrl(domainUri, route, current, mode).ToString();
                        return route;
            return null;
  • Kevin Jump 1150 posts 6832 karma points MVP 2x c-trib
    Apr 16, 2018 @ 18:57
    Kevin Jump

    Hi Remi,

    I think you need to look at implimenting an IContentFinder class.

    Content Finders can be injected into the Umbraco Request Pipeline, and you can write code in them to work out what page should be shown based on the URL.

    There is quite a good article on Content Finders here :

    With a content finder you could take your base theme page, and workout the product portion of the URL to redirect umbraco to the correct template.

    You will almost certainly want to write a URL Provider too - They are like the reverse of a content finder in that given a peice of content you can work out what the URL(s) will be.

  • Remi Martel 32 posts 103 karma points
    Apr 16, 2018 @ 19:28
    Remi Martel

    Thanks. I'll look more into the Content Finder and tell you if it works

Please Sign in or register to post replies

Write your reply to: