umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
Other
4.49k stars 2.69k forks source link

v8: Routing by template is not working anymore #5290

Closed RobK073 closed 5 years ago

RobK073 commented 5 years ago

In the previous version (7) I could route my (template)page by a TemplateName. If I do the same thing in 8, umbraco returns a 404.

Reproduction

In 7 I created a DocumentType with 2 or more templates. If I created a contentpage based on this documenttype I could give the templatename with it like this www.example.com/myPage/TemplateName and it returns the right template. In 8 this isn't working anymore, I get a 404. I used this before to acces my CRUD templates so it was very easy.

I have everything retested with a clean 7 and a clean 8 installation without starterkits.

nul800sebastiaan commented 5 years ago

You can still use ?altTemplate=TemplateName - not sure if we are going to support the other method where the template name is added to the URL, I'll ask around.

nul800sebastiaan commented 5 years ago

Heard back: this is still supported if you must, you can do composition.ContentFinders().Append<ContentFinderByUrlAndTemplate>() in a composer.

The way altTemplates and routing are handled is a bit odd and convoluted so we're not enabling it by default so as not to encourage it too much.

RobK073 commented 5 years ago

Hi Sebastiaan,

Thx, that is what I m looking for. I have tested it and it works :)

cpevans commented 5 years ago

@RoboDot can you post an example of how to implement this? or @nul800sebastiaan is there any documentation about how to achieve this?

was a useful feature in v7 and would be good to know the best practice for enabling it in Umbraco 8

dawoe commented 5 years ago

@nul800sebastiaan should this be documented ?

marcemarc commented 5 years ago

The ability to manipulate the list of ContentFinders in a composition is documented:

https://our.umbraco.com/Documentation/Reference/Routing/Request-Pipeline/IContentFinder

but not the change to the default behaviour of altTemplate (but I sort of think that wasn't 'documented' in V7 either... but more part of Umbraco folklore (we used to cover it in the L2 training though) so it is going to surprise folk could add a note to the IContentFinder docs page above to that affect!

have added an example on the forum post: https://our.umbraco.com/forum/using-umbraco-and-getting-started/99794-alternativ-template