At the moment in 4.11 and 6.x we disable altTemplate as soon as we're not displaying the document that
exactly matches the url, either because of internal redirects, or
because there was no document with that url and we're displaying the 404
page, or because there was a document but you don't have access to it
and we're displaying the login page, whatever.
Do you feel this is appropriate? Do you have a different opinion?
But what about backward compatibility? Does that mean that if i upgrade my website that uses ?altTemplate feature to v 4.11 or v6 it will not work anymore?
Dummy question here...why are these settings not just default in the web.config? Is it because it has a concequence wether you're running MVC mode or not?
From the previous post it sounds like one needs to declare the the stuff in the web.config manually - or do I misunderstand? Will these secions be in the web.config by default and then it's just a matter of setting internalRedirectPreservesTemplate="false" to "true" in order to enable it?
Ah... yes you need to declare the stuff in web.config... and it's not already there. I guess the goal is to have it by default (now I see what you mean) and then you can change the settings. However, I understand we want to refactor how settings work for v7 and this is a rather "confidential" config (ie it was create for Jeroen, really) so it's not by default in web.config.
I just downloaded 6.1.1 and in the umbracoSettings.config I found internalRedirectPreservesTemplate="false". Do I still need to do all those web.config changes or can I just set it to true?
Internally we use UmbracoSettings.For<WebRouting>().InternalRedirectPreservesTemplate which, if the new web.config /umbraco/web.routing section is present, will use its value. Otherwise it will fall back to using UmbracoSettings.InternalRedirectPreservesTemplate which gets the value of /settings/web.routing/@internalRedirectPreservesTemplate from within umbracoSettigns.config.
So you can just set it to true in umbracoSettings.config.
The joy of migrating to new solutions while remaining backward compatible...
I've set internalRedirectPreservesTemplate="true" in config/umbracoSettings.config I have my alt template in Views/my-alt-template.cshtml
but when have tried to surf up my alt template using /path-to-my-node/my-alt-templat I still get the umbraco 404 intentionally ugly page. (am using 6.1.2)
At the moment (6.1) the pipeline runs those content finders:
One that will look for /path/to/page
One that will look for /path/to/page/template
One that will look for /alias
But it does not run a content finder that would look for /alias/template. Mainly because that was not supported in the old, 4.x pipeline. But it should be fairly straightforward to implement such a finder, should you really need one. Probably just need a bit of copy-and-paste from the existing finders.
the site I'm working on is actually a 4.x project that I've upgraded to 6 and am converting my templates to Mvc. So I'm a bit confused that you say /alias/template wasn't supported in the old pipeline because for the site in question that's exactly how it used to work :) meaning that I don't think I had to do anything special in order to achieve it.
Can do by configuration. You'll want to look at how the current finders are implemented, do your own, then register it via an ApplicationEventHandler... you'll want to have a look at http://www.zpqrtbnk.net/TheUmbraco6RequestPipeline.pdf to better understand. I would have done it already for you... but I'm more than busy at the moment. Feel free to ask questions, though.
Can do by configuration. You'll want to look at how the current finders are implemented, do your own, then register it via an ApplicationEventHandler... you'll want to have a look at http://www.zpqrtbnk.net/TheUmbraco6RequestPipeline.pdf to better understand. I would have done it already for you... but I'm more than busy at the moment. Feel free to ask questions, though.
Hi Stephen, thanks for replying so quickly. I've read through the pdf but only about 5% of it makes any sense to me unfortunately ( the part about having a v5 moment especially struck a chord :) my first question is where do the current finders hang out?
You had me all ears at 'copy-and-paste' but now I'm feeling full of inadequacy and self loathing for my inability to fathom ApplicationEventHandlers and public interface IUrlProviders :(
Ok, another question.... So I would need to add something like this in Global.asax ?
public class CustomApplicationEventHandler : ApplicationEventHandler { protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { DefaultRenderMvcControllerResolver.Current.SetDefaultControllerType(typeof(MyCustomUmbracoController)); base.ApplicationStarting(umbracoApplication, applicationContext); } }
It's the next part that I dont get. (and probably have no hope of achieving) Writing my own Custom Umbraco Controller and having it look for an extra route (altTemplate) when UmbracoUrlAlias is used
Will try to cool down your brain ;-) No, you don't want to write a controller. You want to write an IContentFinder. There are stuff in the PDF about IContentFinder, with sample finders and how to register them (using the resolver in an application event handler). Then you'll want to look at the original code for Umbraco.Web/Routing/ContentFinderByNiceUrl.cs, ContentFinderByUrlAlias.cs and ContentFinderByNiceUrlAndTemplate.cs... you'll want to take bits of both to create your own ContentFinderByUrlAliasAndTemplate.cs.
Sorry I can't give you code here... I'm away on vacation with an unstable 3G network link and very little time... hope you'll find your way!
I'm a bit confused but somehow have inadvertently solved this (perhaps because of my earlier hurried testing). switching internalRedirectPreservesTemplate back to false and making sure that when you reference your alt template that you dont add the trailing slash / then the alt template is found and works with both: /urlAlias/alt-template /real-path-to-node/node/alttemplate
What shall we do with AltTemplate?
At the moment in 4.11 and 6.x we disable altTemplate as soon as we're not displaying the document that exactly matches the url, either because of internal redirects, or because there was no document with that url and we're displaying the 404 page, or because there was a document but you don't have access to it and we're displaying the login page, whatever.
Do you feel this is appropriate? Do you have a different opinion?
Stephan
If it's an internal redirect I think the AltTemplate should still be enabled.
Jeroen
Has a decision already been made about this?
Jeroen
No decision, so 6.1 will by default _not_ enable the alt template on internal redirect, but come with a config option to re-enable it.
If it can be enabled with a config that's perfect :-).
Jeroen
But what about backward compatibility? Does that mean that if i upgrade my website that uses ?altTemplate feature to v 4.11 or v6 it will not work anymore?
Now that 6.1 is out what is the config option where we can change this?
Jeroen
You need to declare a web.config section:
And then set the config (also in web.config):
And then it should work. An internal redirect should not reset the altTemplate anymore.
Let me know if that's OK!
Hi Stephen
Dummy question here...why are these settings not just default in the web.config? Is it because it has a concequence wether you're running MVC mode or not?
/Jan
Not sure I understand... what do you mean by "not just default in the web.config"?
From the previous post it sounds like one needs to declare the the stuff in the web.config manually - or do I misunderstand? Will these secions be in the web.config by default and then it's just a matter of setting internalRedirectPreservesTemplate="false" to "true" in order to enable it?
/Jan
Ah... yes you need to declare the stuff in web.config... and it's not already there. I guess the goal is to have it by default (now I see what you mean) and then you can change the settings. However, I understand we want to refactor how settings work for v7 and this is a rather "confidential" config (ie it was create for Jeroen, really) so it's not by default in web.config.
But, to answer your question: not yet. Should be.
I just downloaded 6.1.1 and in the umbracoSettings.config I found internalRedirectPreservesTemplate="false". Do I still need to do all those web.config changes or can I just set it to true?
Jeroen
Internally we use UmbracoSettings.For<WebRouting>().InternalRedirectPreservesTemplate which, if the new web.config /umbraco/web.routing section is present, will use its value. Otherwise it will fall back to using UmbracoSettings.InternalRedirectPreservesTemplate which gets the value of /settings/web.routing/@internalRedirectPreservesTemplate from within umbracoSettigns.config.
So you can just set it to true in umbracoSettings.config.
The joy of migrating to new solutions while remaining backward compatible...
Hi Stephen,
I've set internalRedirectPreservesTemplate="true" in config/umbracoSettings.config
I have my alt template in Views/my-alt-template.cshtml
but when have tried to surf up my alt template using /path-to-my-node/my-alt-templat
I still get the umbraco 404 intentionally ugly page.
(am using 6.1.2)
Have I missed something obvious?
Did you also create it as a template in the umbraco backoffice? Only having it in the views folder probably isn't good enough.
Jeroen
Hi Jeroen,
Yep, I've got it in the back office as well,
Ah! found the problem
the node I was using also happens to have an UmbracoUrlAlias
so if I do this:
I get the 404
but if I do this:
It Works!
thats kind of awesome that you used to be able to use UmbracoUrlAliases together with alttemplates
what would the easiest work around be? (I'm guessing its just not built to work that way)
thanks
- Tim
Hey,
At the moment (6.1) the pipeline runs those content finders:
But it does not run a content finder that would look for /alias/template. Mainly because that was not supported in the old, 4.x pipeline. But it should be fairly straightforward to implement such a finder, should you really need one. Probably just need a bit of copy-and-paste from the existing finders.
Stephan
Cool, sounds promising!
is that something I can already do by configuration somewhere?
if not, maybe I can add it as a feature request to http://issues.umbraco.org
the site I'm working on is actually a 4.x project that I've upgraded to 6 and am converting my templates to Mvc. So I'm a bit confused that you say /alias/template wasn't supported in the old pipeline because for the site in question that's exactly how it used to work :) meaning that I don't think I had to do anything special in order to achieve it.
- Tim
Can do by configuration. You'll want to look at how the current finders are implemented, do your own, then register it via an ApplicationEventHandler... you'll want to have a look at http://www.zpqrtbnk.net/TheUmbraco6RequestPipeline.pdf to better understand. I would have done it already for you... but I'm more than busy at the moment. Feel free to ask questions, though.
Can do by configuration. You'll want to look at how the current finders are implemented, do your own, then register it via an ApplicationEventHandler... you'll want to have a look at http://www.zpqrtbnk.net/TheUmbraco6RequestPipeline.pdf to better understand. I would have done it already for you... but I'm more than busy at the moment. Feel free to ask questions, though.
Hi Stephen, thanks for replying so quickly.
I've read through the pdf but only about 5% of it makes any sense to me unfortunately ( the part about having a v5 moment especially struck a chord :)
my first question is where do the current finders hang out?
You had me all ears at 'copy-and-paste' but now I'm feeling full of inadequacy and self loathing for my inability to fathom ApplicationEventHandlers and public interface IUrlProviders :(
- Tim
Ok, another question....
So I would need to add something like this in Global.asax ?
It's the next part that I dont get. (and probably have no hope of achieving)
Writing my own Custom Umbraco Controller and having it look for an extra route (altTemplate) when UmbracoUrlAlias is used
I've looked in the pdf quite a few times and in the Umbraco Source for anything that made sense to me or where the default finders might be to copy from.
I guess these are relevant?
https://github.com/umbraco/Umbraco-CMS/blob/a132f609d789a9984ebe123e7c30b9230851d603/src/Umbraco.Web/Routing/AliasUrlProvider.cs
https://github.com/umbraco/Umbraco-CMS/blob/a132f609d789a9984ebe123e7c30b9230851d603/src/Umbraco.Web/Configuration/WebRouting.cs
help please, anyone. my brain is melting.
- Tim
Will try to cool down your brain ;-) No, you don't want to write a controller. You want to write an IContentFinder. There are stuff in the PDF about IContentFinder, with sample finders and how to register them (using the resolver in an application event handler). Then you'll want to look at the original code for Umbraco.Web/Routing/ContentFinderByNiceUrl.cs, ContentFinderByUrlAlias.cs and ContentFinderByNiceUrlAndTemplate.cs... you'll want to take bits of both to create your own ContentFinderByUrlAliasAndTemplate.cs.
Sorry I can't give you code here... I'm away on vacation with an unstable 3G network link and very little time... hope you'll find your way!
But feel free to ask questions.
Stephan
I'm a bit confused but somehow have inadvertently solved this (perhaps because of my earlier hurried testing).
switching internalRedirectPreservesTemplate back to false and making sure that when you reference your alt template that you dont add the trailing slash / then the alt template is found and works with both:
/urlAlias/alt-template
/real-path-to-node/node/alttemplate
Related to this:
http://our.umbraco.org/forum/templating/templates-and-document-types/28785-altTemplate-alias-with-trailing-slash
but from reading that it sounds as though this issue had been addressed.
I have
<addTrailingSlash>true</addTrailingSlash> in my umbracosettings.config
Ideally I would also expect it to work with the forward slash, but right now I'm so happy that it just works and I dont have to write any C# code :)
thanks,
- Tim
is working on a reply...