Copied to clipboard

Flag this post as spam?

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


  • Ranjit J. Vaity 66 posts 109 karma points
    Mar 06, 2010 @ 21:35
    Ranjit J. Vaity
    0

    Creating Templates in Umbraco 4

    Hi All,

    I been working in Umbraco since last couple of years. I also been working in another CMS called EPiServer(I am not sure, if you as a reader has developed any application using EPiServer).

    Still back in Umbraco 3, this did not concern me much as we created templates and stored them in db directly. I missed the code-behind feature here.

    And ofcourse, Umbraco still remains my Favorite CMS.

    This talk is about Creating templates:

    If I need to compare this feature with EPiserver CMS 5. We need to create an .aspx page and in code-behind extend that class from TemapatePage class from EPiServer api. (And developer can take advantage of all code-behind feature and still use master pages)

    Finally we need to create a document type (called Page type in EPiServer) where we specify the relative path to that .aspx page(template in EPiServer). Next is as similar as Umbraco, we go ahead by adding properties and creating pages using those document types.

    On the other side in Umbraco 4, When we create a template. It creates .master file in masterpages folder and every child template is .Master file here. Which is not very conviencing at least to me. As in ASP.NET have specific uses for each of these file type(.master and .aspx).

    I wish to know the reason behind, 

    1. Why did developers choose to go with .master file and not by .aspx and .aspx.cs files when we create a template?

    2. Do we have any future plan where we will be using .aspx files as template and get to use code-behide feature?

    3. Or is there any way where we use .aspx files in Umbraco (I might be unknown to this)?

    Your contributions to this discussion will be appreciated.

    Thank you in advance.

    Regards ,

    Ranjit J. Vaity

    NOTE: Do not wish to be offensive toward our awesome Umbraco community by comparing 2 CMSs.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Mar 07, 2010 @ 02:25
    Aaron Powell
    1

    You're correct that Master and ASPX are different concepts in ASP.NET, and understanding those differences will help understand why Umbraco uses Master Pages.

    A Master Page is essentially a template for .NET, defining outlying structure, global functionality, etc. This is exactly what they are in Umbraco. Although Umbraco doesn't generate a backing file and inherited class there's nothing that would stop you doing it yourself. In fact, I've done it quite a few time.

    Umbraco doesn't generate actual files to represent a page, so having an ASPX is pointless, Umbraco generates its pages on the fly, not at publish time.

    I wouldn't expect this to change in v5 (it wont change in v4.x) either.

    You can always create custom ASPX pages which are stored outside of Umbraco, you just need to specify it as a reserved URL and Umbraco will ignore it.

  • Ranjit J. Vaity 66 posts 109 karma points
    Mar 07, 2010 @ 20:33
    Ranjit J. Vaity
    0

    Hi Slace,

    I understand you point when you say we use master page for defining outlining structure. And also about reserved URLs, which is not what I wanted to do. Instead use .aspx page as a template file, where I can place my macros(usercontrols) and take advantage of code-behind. But as per your reply that cannot be the case.

    I want to thank you very much for your reply.

    Cheers!

    Ranjit J. Vaity

     

     

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Mar 07, 2010 @ 20:47
    Peter Dijksterhuis
    0

    Am I misunderstanding something here? 

    If you have usercontrols with codebehind, create a macro for that usercontrol and then you can simply place that macro within a template in umbraco.

    Isn't that offering the same functionality?

    Peter

  • jaygreasley 416 posts 403 karma points
    Mar 07, 2010 @ 20:49
    jaygreasley
    0

    Hi Ranjit,

    You could write a custom user control and insert that into your template. This can utilise the code-behind coding model.

    tht

    Jay

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Mar 07, 2010 @ 22:43
    Aaron Powell
    0

    I don't get why people are wanting to put functionality into the Page code behind so much, I haven't added functionality into a Page class for a very long time, and even then it's only been something like a property which is just a wrapper for a commonly used piece of code.

    Using Page makes it hard to decouple code and decoupling is something that I see to be very important.

    But using ASPX as a template goes against the point of introducing the Master Page in .NET 2.0.
    I remember using .NET 1.1 and ASPX-as-template which was just a bunch of user controls everywhere.

    ASPX doesn't support UI nesting, again another reason why it's not useful as a template.

  • Ranjit J. Vaity 66 posts 109 karma points
    Mar 08, 2010 @ 06:41
    Ranjit J. Vaity
    0

    Hi Slace,

    I truly believe that adding .master pages instead others as Umbraco templates should have a very strong reason to support.

    Cool, the above post might be the proper reason I was looking out for. This clears my doubt.

    Thanks for clarifying this to me.

    Peter and Jaygreasley thank you for your contribution.

    Cheers,

    Ranjit J. Vaity

     

     

     

  • Chris Lord 15 posts 51 karma points
    Apr 01, 2011 @ 19:38
    Chris Lord
    0

    Hi,

    Does anyone know how I can change the master page of a master page in code?  I have three umbraco templates (English.Master, German.Master and Page.Master)

    In Page.Master, I have set the MasterPageFile to English.Master and that all works great. However, I have a requirement to need to change Page.Master MasterPageFile to German.Master dynamically (either as a result of a property value that the CMS editor enters or something in the query string).

    I am aware in .NET that you can change the master page of an aspx page in the PreInit event, but Master pages don't have this, so am stuck.....

    Any ideas on how I can acheive this without having a different Page.Master which uses the German.Master (there may be more countries added later and don't want to start the wrong way :-) )

    Cheers

    Chris

Please Sign in or register to post replies

Write your reply to:

Draft