Copied to clipboard

Flag this post as spam?

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


  • Stephen 767 posts 2273 karma points c-trib
    Jan 30, 2013 @ 15:37
    Stephen
    0

    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

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 30, 2013 @ 15:41
    Jeroen Breuer
    0

    If it's an internal redirect I think the AltTemplate should still be enabled.

    Jeroen

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Feb 27, 2013 @ 09:48
    Jeroen Breuer
    0

    Has a decision already been made about this?

    Jeroen

  • Stephen 767 posts 2273 karma points c-trib
    Feb 27, 2013 @ 10:48
    Stephen
    0

    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.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Feb 27, 2013 @ 10:50
    Jeroen Breuer
    0

    If it can be enabled with a config that's perfect :-).

    Jeroen

  • Sergey 5 posts 25 karma points
    Feb 27, 2013 @ 14:20
    Sergey
    0

    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?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    May 30, 2013 @ 17:30
    Jeroen Breuer
    0

    Now that 6.1 is out what is the config option where we can change this?

    Jeroen

  • Stephen 767 posts 2273 karma points c-trib
    May 30, 2013 @ 17:38
    Stephen
    2

    You need to declare a web.config section:

    <sectionGroup name="umbraco">
        <section name="web.routing" type="Umbraco.Web.Configuration.WebRouting,umbraco" requirePermission="false" />
    </sectionGroup>

    And then set the config (also in web.config):

    <umbraco>
        <web.routing internalRedirectPreservesTemplate="false" />
    </umbraco>

    And then it should work. An internal redirect should not reset the altTemplate anymore.

    Let me know if that's OK!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 30, 2013 @ 19:02
    Jan Skovgaard
    0

    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

  • Stephen 767 posts 2273 karma points c-trib
    May 30, 2013 @ 19:03
    Stephen
    0

    Not sure I understand... what do you mean by "not just default in the web.config"?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 30, 2013 @ 19:13
    Jan Skovgaard
    0

    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

  • Stephen 767 posts 2273 karma points c-trib
    May 30, 2013 @ 19:16
    Stephen
    0

    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.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jun 03, 2013 @ 11:01
    Jeroen Breuer
    0

    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

  • Stephen 767 posts 2273 karma points c-trib
    Jun 04, 2013 @ 11:23
    Stephen
    1

    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...

  • wolulcmit 357 posts 693 karma points
    Jul 08, 2013 @ 17:32
    wolulcmit
    0

    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?

     

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jul 08, 2013 @ 17:34
    Jeroen Breuer
    0

    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

  • wolulcmit 357 posts 693 karma points
    Jul 08, 2013 @ 17:59
    wolulcmit
    0

    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:

    /my-nodes-url-alias/my-alt-template

    I get the 404
    but if I do this:

    /my-nodes-parent/my-nodes-real-location/my-alt-template

    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

  • Stephen 767 posts 2273 karma points c-trib
    Jul 08, 2013 @ 18:48
    Stephen
    0

    Hey,

    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.

    Stephan

  • wolulcmit 357 posts 693 karma points
    Jul 09, 2013 @ 03:29
    wolulcmit
    0

    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

  • Stephen 767 posts 2273 karma points c-trib
    Jul 09, 2013 @ 08:35
    Stephen
    0

    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.

  • Stephen 767 posts 2273 karma points c-trib
    Jul 09, 2013 @ 08:42
    Stephen
    0

    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.

  • wolulcmit 357 posts 693 karma points
    Jul 09, 2013 @ 15:58
    wolulcmit
    0

    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



  • wolulcmit 357 posts 693 karma points
    Jul 19, 2013 @ 08:43
    wolulcmit
    0

    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

    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

     

  • Stephen 767 posts 2273 karma points c-trib
    Jul 19, 2013 @ 21:07
    Stephen
    0

    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

  • wolulcmit 357 posts 693 karma points
    Jul 24, 2013 @ 08:45
    wolulcmit
    0

    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



     

Please Sign in or register to post replies

Write your reply to:

Draft