Copied to clipboard

Flag this post as spam?

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


  • Peter Duncanson 430 posts 1360 karma points c-trib
    Apr 05, 2010 @ 20:23
    Peter Duncanson
    0

    Not a problem more a suggestion regarding default masterpages

    Now knowing how funky Umbraco is I'm sure there is a way to do this already which I just dont know about (and if so I'd love to hear about it).

    I'm rubbish at remembering what sections I have created for my master pages and I keep, keep, keep getting the dreadded:

    "Cannot find ContentPlaceHolder 'ContentPlaceHolderDefault' in the master page '/masterpages/MasterTemplate.master', verify content control's ContentPlaceHolderID attribute in the content page."

    Error which simply means (for you Googlers) that I don't have a section in my template with the ID that the parent section/master page is expecting (think of it as a missing include file).

    So tired of this happening time and again on a site I'm building I took it upon myself to find the file where the default masterpage template is and hack it to include all my sections from the off. Now this is not a clever code solution, its more a Textpad (other text editors are available) type solution, but it works.

    So go find the file in question which should be at /umbraco/masterpages/default.Master copy it so you have a back up then open it in your fav text editor.

    Then add in as many sections as you need/want. Mine now looks like this:

    <%@ Master Language="C#" MasterPageFile="/masterpages/MasterTemplate.master" AutoEventWireup="true" %>

    <asp:content ContentPlaceHolderId="customerHeaderCode" runat="server"></asp:content>

    <asp:content ContentPlaceHolderId="mainBanner" runat="server"></asp:content>

    <asp:content ContentPlaceHolderId="body" runat="server"></asp:content>

    <asp:content ContentPlaceHolderId="customJavascript" runat="server"></asp:content>

     

    Would love to be able to comment up my template but I can't seem to find a comment that won't break .net other than putting <!-- --> on the inside of the content blocks which ain't what I want to do.

    Anyway, seems to work, thought I'd pass it on. Any better ways of achieving this?

     

     

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Apr 05, 2010 @ 20:34
    Sebastiaan Janssen
    0

    I'm not sure what you're trying to solve here? As soon as you create a new masterpage in the Umbraco backend, it will automatically inherit the placeholders from the umbraco masterpage. Just create your own placeholders (customHeaderCode, mainBanner, etc.) in this one and nest your masterpages under there.

    As for commenting that will not appear in the frontend, use <%-- --%> for that.

  • Peter Duncanson 430 posts 1360 karma points c-trib
    Apr 05, 2010 @ 21:18
    Peter Duncanson
    0

    I forget what all my content sections are called though, thats what I was trying to solve. Having all the options in one file for easy reference seemed like a good idea.

    Thanks for the comment tip I'll try it out.

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Apr 05, 2010 @ 21:51
    Sebastiaan Janssen
    1

    Ah, well here's the real pro tip: Edit your masterpages in visual studio. I just get code completion as soon as I type ContentPlaceHolderID=" :D

  • Peter Duncanson 430 posts 1360 karma points c-trib
    Apr 05, 2010 @ 22:21
    Peter Duncanson
    0

    Ohhh I like that one, nice tip. Will be trying that from now on.

    Cheers Sebastiaan as always :)

  • Peter Duncanson 430 posts 1360 karma points c-trib
    Apr 19, 2010 @ 21:06
    Peter Duncanson
    0

    Also for the record there is a better way within Umbraco. You can just use the "Insert content area" button when editing a template, gives you a drop down of all available content placeholder ids. Genius.

Please Sign in or register to post replies

Write your reply to:

Draft