Copied to clipboard

Flag this post as spam?

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


  • moo123 4 posts 24 karma points
    May 17, 2011 @ 21:21
    moo123
    0

    Am I using ContentPlaceHolderId wrong?

    Why is the footer and header not appearing after I create an aspx page based on the below template code? For example:  If I create a "newpage.aspx" and use master, I do not see the footer or the header. If I make a "newpage.aspx" and use the template header, I only see header but not the footer. Why cant I see both?

    MASTER template

        <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
        <head>
        </head>
        <body>
          
        <asp:ContentPlaceHolder Id="header" runat="server"></asp:ContentPlaceHolder>
        <asp:ContentPlaceHolder Id="footer" runat="server"></asp:ContentPlaceHolder>
        </body></html>
        </asp:Content>


    Master (child node: header) template:

        <asp:content ContentPlaceHolderId="header" runat="server">TEST</asp:content>


    Master (child node: footer) template:

        <asp:content ContentPlaceHolderId="footer" runat="server">TEST</asp:content>

    I have 3 doc types (master, header, footer) with the id of header and footer. Each link to their own template

     

    Thanks a lot!

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 17, 2011 @ 21:28
    Jan Skovgaard
    0

    Hi Moo123

    Ehm...

    So you're having a template for both header and footer content? Why is that? Usually you would want header and footer to appear on all of your pages, or am I missing something?

    If you write "Footer" and "HEAER" as text in your contentplaceholders in your mastertemplate, these texts should appear on the two other templates. At the moment the footer text on the header template is empty, since you only have a content area for header in it and vice versa for your footer template.

    Does this make sense to you?

    /Jan

  • moo123 4 posts 24 karma points
    May 17, 2011 @ 21:40
    moo123
    0

    Jan, could I build a site with only 1 template? I thought that for every user editable DIV you would need a template, doc type (for user control) and content page. Am I making this more difficult then it needs to be?  I just want to make a simple page with a header and footer and allow users to edit it.

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 17, 2011 @ 22:32
    Jan Skovgaard
    0

    Hi Moo123

    Yes you could do that...but it's really not desirable to do it that way, but it's possible :-)

    But you need to think about what elements of your site is going to be the same on each page.

    Usually that means your header and your footer, which should then be on your master template (This does not mean it can't be changed dynamically - for instance you will want to make sure that your page titles and meta description are unique for each page...and that's also possible to achieve easily).

    But in short, yes you're making it a bit harder than it should be :-)

    I sense you're a bit confused and that perfectly ok since you're only just getting started.

    I think you could really benefit from installing the Creative Website starter package and have a look at how it's been build and how the templates are structured. I think that you will get a lot more from that than by me trying to explain it in written words.

    You can install the CWS package from within the developer section in Umbraco, by expanding the "packages" folder and go to the "Umbraco package repository" and from there choose "starter kits". Click on the "Creative website starter package" and follow the instructions.

    I hope this helps - othwerwise don't hesitate to ask further questions :-)

    /Jan

  • moo123 4 posts 24 karma points
    May 18, 2011 @ 19:22
    moo123
    0

    Jan, thank you for the advice. I have installed the packet and watched many tutorials online.  I think I understand how everything works now, but still when I create my own footer and header (each one as a richtext box doc type)  I do not see it when I render it as an aspx file.

    This is my new code. If you can, please take a look at it.  I think the problem is after I add contents to the the richtext editor tab and save, umbraco cant find that instance in the aspx page eventhough I specify the idname.

    TEMPLATES:

    MASTER (HOMEPAGE. FOOTER HEADER)

    All link to Master template. (Master is none)

    Create doc type for each with same name and alias. Add tab contents for each doc with own ID name. Make it recursive, and alllow Footer and Header to be  child nodes of Homepage. 

    I then place this code in the master

    <asp:Content ContentPlaceHolderId="ContentPlaceHolderDefault" runat="server"> 
     <asp:ContentPlaceHolder Id="Header" runat="server">asp:contentplaceholder>
     <asp:ContentPlaceHolder Id="Footer" runat="server">asp:contentplaceholder>


    ..In Homepage temple I link it to master, and I  type this code:

    <asp:Content ContentPlaceHolderID="Header" runat="server">
    <umbraco:Item field="headertextbox" 
    recursive="true" runat="server">umbraco:Item>
    <asp:Content>
       
    <asp:Content ContentPlaceHolderID="Footer" runat="server">
    <umbraco:Item field="footertextbox" 
    recursive="true" runat="server">umbraco:Item>
    <asp:Content>

     

    I place images and text into these richtextboxes and save and publish and I do not see them appear. What is wrong still?

    Thank you very much

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 18, 2011 @ 22:18
    Jan Skovgaard
    0

    Hi Moo

    Ok...let's see if I can manage to explain this in a good way :-)

    In order to make sure your header and footer text gets displayed on all of your pages the text really should be placed on the master template - otherwise you would need to write the code from your homepage template in the other templates as well.

    Now...where do you place the header and footer text? On your homepage document type? Then the information should be shown on your homepage only and not in the other templates.

    Could you explain your content structure a bit more since I'm a bit unsure how you have structured your content section etc.

    /Jan

  • moo123 4 posts 24 karma points
    May 18, 2011 @ 22:45
    moo123
    0

    Jan thank you for your reply!

     

    In order to make sure your header and footer text gets displayed on all of your pages the text really should be placed on the master template -

    I just put everything on the Master for testing after I read your post: Now I have code similar to this in the master: However the text in the richtext editor doesnt appear on the page still.

     <asp:ContentPlaceHolder Id="Header" runat="server"><umbraco:Item field="headerbox" recursive="true" runat="server"></umbraco:Item></asp:ContentPlaceHolder>

    Now...where do you place the header and footer text? On your homepage document type? Then the information should be shown on your homepage only and not in the other templates.

    I write text into the richtext box in content page I build.The content page page has an id and alias of headerbox. I call it in either the Master, or the hompage template and it doesnt display.

    Could you explain your content structure a bit more since I'm a bit unsure how you have structured your content section etc.

    Templates:

    Master -sub templates (homepage, footer, header)

    master (contains html, css, and asp content tags with same id as above sub templates.)

    sub templates: footer, header:  (each one has the umbraco item tag in it that links to rich text editors content) <-these display one by one, by not as a whole on the homepage.

    sub template Homepage:  brings everything together. (auto built when created.) I just add the item between the asp content tags.

    Example:

    asp:content ContentPlaceHolderId="Header" runat="server">
      <umbraco:Item field="headerbox" textIfEmpty="didnt work" recursive="true" runat="server"></umbraco:Item>
     
    </asp:content>

    <asp:content ContentPlaceHolderId="His_Story" runat="server">
      <umbraco:Item field="footerbox" textIfEmpty="didnt work" recursive="true" runat="server"></umbraco:Item>
     
    </asp:content>

    Then I have a doc type of:

    Master, homepage, header(property headerbox), footer (property footerbox)

    Then I create Content pages called Master(template master), homepage(template hompage), header(template header), and footer(template footer)

    I enter data into richtext boxes for header and footer and click publish.

    .IF I view the homepage only the master displays. IF  I view the header, only the header will display. IF  I view footer, only footer displays.  I cant get them to all display at once.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 19, 2011 @ 07:29
    Jan Skovgaard
    0

    Hi Moo

    Ok...

    What would your content structure look like?

    Do you create at structure in the content tree like this...

    Homepage
       page
       page
       page

    I'm still not sure why you'll want header and footer as separate templates and document types?. I think that I would create some properties on the Homepage document type for instance, containing tabs called "footer" and "header" where you can add a rich text property to enter the data.

    Then you should be able to see it by calling these fields in the master template or the homepage template. But you will not be able to see it on textpages for instance.

    To do that you would need to make a macro in XSLT or Razor, which shows the content of the root node, which in this case would be "Homepage".

    I think you need to rethink your approach.

    What I would do is to create three document types in this hierachy

    Master
       Homepage
       Textpage

    Those tabs and properties that will be the same on both homepage and text page I would create on the Master document type...for instance a SEO tab with properties for title, keywords and description.

    Then I would define what should be possible to enter on Homepage and Textpage.

    I would then create three templates with a hierachy like this

    Master
      Homepage
      Textpage

    Make sure that the templates are attached to the document types (Not the master document type, but the two others since our master document type is not used for content but more like a placeholder).

    In the master template try to make some static HTML at first.

    In the content section create a structure like this

    Homepage
       textpage
       textpage
       textpage

    When they're created and published, try going to the Hompeage....now you should be able to see the static HTML you entered in the master template.

    If you see this content everything is good and you're now ready to experiment with creating contentplaceholders for the content that should come from textpage and homepage and otherwise setup your mastertemplate with all the things that needs to be reused on the content-pages.

    I hope this helps.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft