Copied to clipboard

Flag this post as spam?

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


  • Tobias Morf 76 posts 169 karma points
    Jul 02, 2013 @ 14:40
    Tobias Morf
    0

    Reuse Document Types with different Templates

    We have a big website with different channels. The channel design changes from year to year and from channel to channel but the document types should stay the same. How can I reuse my current document types?

    It would be no problem for us to define a separate template on the root level.

    The problem is that a lot of editors are working with this website and they don't want to change the template when they create, for example, a new news entry. Can I set the template dynamically or programmatically based on the chosen root template or is there a better/other approach?

  • Jeroen Breuer 4860 posts 12121 karma points MVP 3x admin c-trib
    Jul 02, 2013 @ 15:10
    Jeroen Breuer
    0

    If you're using 4.10 or higher you could use route hijacking and return a different view in the controller.

    Jeroen

  • Tobias Morf 76 posts 169 karma points
    Jul 02, 2013 @ 15:22
    Tobias Morf
    0

    We have version 4.11.8. But everything is based on web forms.

  • Rich Green 2245 posts 3913 karma points
    Jul 02, 2013 @ 15:26
    Rich Green
    1

    Hey Tobias,

    You could use AltTemplate http://www.nibble.be/?p=42

    Rich

  • Tobias Morf 76 posts 169 karma points
    Jul 02, 2013 @ 15:31
    Tobias Morf
    0

    Thank you but we can't use this feature.

    First, it looks unaesthetic even when you do it via directory url (www.your.url/name_of_alt_template/) and
    second, the url structure changes (www.channel1.com/games will be www.channel2.com/games/name_of_alt_template/)

  • Rich Green 2245 posts 3913 karma points
    Jul 02, 2013 @ 15:35
    Rich Green
    0

    You can also swap out the Master template via code, this was a couple of lines of .NET code if I remember rightly.

    Rich

  • Tim Geyssens 6419 posts 15036 karma points MVP 2x c-trib
    Jul 02, 2013 @ 15:36
    Tim Geyssens
    0

    Yeah just set the correct template if it depends on the template set on parent docs, shouldn't be that hard using the event model

  • Tobias Morf 76 posts 169 karma points
    Jul 02, 2013 @ 15:37
    Tobias Morf
    0

    Is there a best practice to do something like this?

  • Rich Green 2245 posts 3913 karma points
    Jul 02, 2013 @ 15:45
    Rich Green
    0

    I wouldn't say there's best practice, the ability to swap the master page is a feature of .NET

    Microsoft use this with Umbraco on TechNet etc. see this video around 27 mins http://stream.umbraco.org/video/2098743/multi-environment-team-based

    Rich

  • Tobias Morf 76 posts 169 karma points
    Jul 02, 2013 @ 15:47
    Tobias Morf
    0

    Ok - thank you.

    So Tim is speaking about the event model of ASP.NET and not of Umbraco?

  • Tim Geyssens 6419 posts 15036 karma points MVP 2x c-trib
    Jul 02, 2013 @ 15:49
    Tim Geyssens
    0

    No in my case I was talking about the event model in Umbraco :)

  • Tim Geyssens 6419 posts 15036 karma points MVP 2x c-trib
    Jul 02, 2013 @ 15:50
    Tim Geyssens
    100

    Here is a snippet but that uses the old API http://our.umbraco.org/wiki/reference/api-cheatsheet/attaching-document-event-handlers/change-the-document's-template but guess that's ok since you are on v4

  • Rich Green 2245 posts 3913 karma points
    Jul 02, 2013 @ 15:52
    Rich Green
    0

    I was talking about changing the Master template on the fly, so not using the Umbraco event model. The code is in that video somewhere, I think he shows it at the end.

  • Tobias Morf 76 posts 169 karma points
    Jul 02, 2013 @ 15:54
    Tobias Morf
    0

    That's what I expected. :-)

    So there are obviously two different approaches. Has anybody out there any experience with one or both?

  • Jeroen Breuer 4860 posts 12121 karma points MVP 3x admin c-trib
    Jul 02, 2013 @ 15:58
    Jeroen Breuer
    0

    Here is a technique where I download the content of another template and display it on the current template: http://our.umbraco.org/forum/developers/extending-umbraco/13984-Url-rewrite-to-make-website-ajax-crawlable#comment51666

    That's another solution I think ;-).

    Jeroen

  • Rich Green 2245 posts 3913 karma points
    Jul 02, 2013 @ 16:00
    Rich Green
    0

    They do two completly different things

    1) Change the master doc type on the fly (no changes to Umbraco) this just presents the node using a different Master template.

    2) Change the template after you've saved a DocType

    From your scenario, I expect 1 would be more useful, you can build business rules into your c#, for example, if year is 2013 then use 2013.master etc.

     

Please Sign in or register to post replies

Write your reply to:

Draft