Copied to clipboard

Flag this post as spam?

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


  • Martin H. Schläger 10 posts 100 karma points
    Oct 31, 2019 @ 18:14
    Martin H. Schläger
    0

    In all old versions of umbraco I was able to create a template without it being attached to a document type and a node and still being able to access it via domain.xx/

  • Amir Khan 1282 posts 2739 karma points
    Oct 31, 2019 @ 18:41
  • Martin H. Schläger 10 posts 100 karma points
    Oct 31, 2019 @ 19:16
    Martin H. Schläger
    0

    So I'll have to write a composer to get this feature back :-/

    Do you know if anyone already has done this?

  • Amir Khan 1282 posts 2739 karma points
    Oct 31, 2019 @ 19:48
    Amir Khan
    0

    I do not, we used that feature a ton for various things and its much more polished than having the altTemplate query string in the URL. I know you could hide it with a rewrite rule but that's kind of a pain also.

    "RoboDot" who started that issue commented that they'd tested it and it worked, maybe reach out to them?

    I don't have a lot of experience with writing Composers.

  • Martin H. Schläger 10 posts 100 karma points
    Oct 31, 2019 @ 19:55
    Martin H. Schläger
    0

    Thanks, yeah... I'm in the same boat as you - I'll see what I can find out and if anything usefull I'll update this thread.

  • Marc Goodson 2126 posts 14218 karma points MVP 8x c-trib
    Nov 01, 2019 @ 08:36
    Marc Goodson
    1

    Composing is a lot scarier than it sounds, and confusing because most of the terms begin with c...

    Anyway there is a page in the docs here with examples:

    https://our.umbraco.com/Documentation/Implementation/Composing/

    but the gist is when Umbraco boots up, it has these 'collections' of different configurations/functionality that 'compose' an Umbraco application.

    It's possible during this boot up, to add or remove items from these collections...

    You can achieve this by creating a c# class file in your project that inherits from a special interface called IUserComposer... Umbraco will look for any c# class that implements this interface during start up and call the 'Compose' method on the class... it's in there that you can do your customisations eg in the case of ContentFinders there is a 'ContentFinderCollection' (see https://our.umbraco.com/Documentation/Reference/Routing/Request-Pipeline/IContentFinder)

    using Umbraco.Core;
    using Umbraco.Core.Composing;
    using Umbraco.Web;
    using Umbraco.Web.Routing;
    
    namespace My.Website
    {
        [RuntimeLevel(MinLevel = RuntimeLevel.Run)]
        public class UpdateContentFindersComposer : IUserComposer
        {
            public void Compose(Composition composition)
            {
                //add our custom MyContentFinder just before the core ContentFinderByUrl...
                composition.ContentFinders().InsertBefore<ContentFinderByUrl, MyContentFinder>();
                //remove the core ContentFinderByUrl finder:
                composition.ContentFinders().Remove<ContentFinderByUrl>();
                //you can use Append to add to the end of the collection
                composition.ContentFinders().Append<AnotherContentFinderExample>();
                //or Insert for a specific position in the collection
                composition.ContentFinders().Insert<AndAnotherContentFinder>(3);
            }
        }
    }
    

    That enables you to add / remove the individual ContentFinders that implement the rules that process the incoming Url..

    The suggestion on the github link is to add the ContentFinderByUrlAndTemplate content finder back into the list of ContentFinders()

    composition.ContentFinders().Append<ContentFinderByUrlAndTemplate>()
    

    to have the V7 functionality back into play for nice urls for AltTemplates!

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft