Copied to clipboard

Flag this post as spam?

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


  • MartinB 411 posts 512 karma points
    Dec 08, 2011 @ 09:13
    MartinB
    0

    Content placeholder in a content placeholder

    Hi there

    I have a master with some content placeholders that load content through content placeholders from either the Homepage or the regular textpages, since they differ quite a bit.

    Though i have some elements that would repeat, but as of now, not so much that i can put them in the master file.

    Is it possible to have a content placeholder in an existing placeholder to load content from a "mini" template?

    I tried the following with no succes:

    <asp:content contentplaceholderid="content" runat="server">
        <div class="contentFrontpage">
            <div class="left">
                <asp:contentplaceholder id="questions" runat="server"></asp:contentplaceholder>             
            </div>
            <div class="right">
                <umbraco:item runat="server" field="bodyText"></umbraco:item>
            </div>
            <div class="clear"></div>
        </div>
    </asp:content>
  • Ernst Utvik 123 posts 235 karma points
    Dec 08, 2011 @ 09:40
    Ernst Utvik
    0

    I think that would work as long as you create a template with the master template set to the template containing the contentplaceholder.

    Something like this, where the markup from your question lies in the submaster and the templates below only reflects changes in the questions contentplaceholder:

    - Master template
        - template
        - submaster
            - template
        -template

  • MartinB 411 posts 512 karma points
    Dec 08, 2011 @ 09:54
    MartinB
    0

    Hi Ernst

    My structure now looks like this:

    Master
       - Homepage
           -Questions
       - Textpage

    In my master i have a contentplaceholder for the content field:

    <asp:contentplaceholder id="content" runat="server"></asp:contentplaceholder>

    The on the Homepage master i have the following:

    <asp:content contentplaceholderid="content" runat="server">
        <div class="contentFrontpage">
            <div class="left">
                <asp:contentplaceholder id="questions" runat="server"></asp:contentplaceholder>             
            </div>
            <div class="right">
                <umbraco:item runat="server" field="bodyText"></umbraco:item>
            </div>
            <div class="clear"></div>
        </div>
    </asp:content>

    In my "Questions template i then have this:

    <%@ Master Language="C#" MasterPageFile="~/masterpages/Homepage.master" AutoEventWireup="true" %>
    <asp:content contentplaceholderid="questions" runat="server">
    <div class="questions"></div>
    </asp:content>

    Which does not output the questions div. Did i misinterpret your example? 

    The div is defined with width, height, etc. and does show up if i insert it seperate from the contentholder.

  • MartinB 411 posts 512 karma points
    Dec 08, 2011 @ 10:07
    MartinB
    0

    I suppose i could just make this through a macro, but i'm actually quite keen on whether this is doable or not?

     

    * edit * and wether it is a good idea to do it through templates and contentplaceholders instead of doing it by macros?

  • MartinB 411 posts 512 karma points
    Dec 08, 2011 @ 13:28
    MartinB
    0

    I think i would prefer that the contentplaceholder within a contentplaceholder method is achieveable since i need to include a Pliable form in the section i need repeated throughout most of the site.

    It would be great if i could just add the reference to the template containing this form in the templates where it's needed. That way i only need to maintain and configure the form and its container div element from one place.

     

  • Ernst Utvik 123 posts 235 karma points
    Dec 09, 2011 @ 10:26
    Ernst Utvik
    0

    I think it should work the way you set it up above. I have a testsite with the same structure that works just fine. Any template gurus got some tips on this?

  • MartinB 411 posts 512 karma points
    Dec 09, 2011 @ 11:18
    MartinB
    0

    Hi Ernst

    Could i persuade you to post the code from your testsite from the different templates, so i can compare if i made any typos or something similar?

     

  • MartinB 411 posts 512 karma points
    Dec 09, 2011 @ 13:46
    MartinB
    0

    I found that if i type some text in the Questions contentplaceholder id it does output it - but i can't get the content from my Questions template to ouput the content from det contentplaceholderid in there.

    <asp:content contentplaceholderid="content" runat="server">
    <div class="contentFrontpage">
    <div class="left">
    <asp:contentplaceholder id="questions" runat="server"> adaasas </asp:contentplaceholder>
    </div>
    <div class="right">
    <umbraco:item runat="server" field="bodyText"></umbraco:item>
    </div>
    <div class="clear"></div>
    </div>
    </asp:content>

    the above outputs "adaasas" but not the following content from the Questions template:

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

    <asp:content contentplaceholderid="questions" runat="server">
    <div class="questions">
    <umbraco:Macro formNode="1143" jQuery="1" Alias="PliableForm" runat="server"></umbraco:Macro>
    </div>
    </asp:Content>


    Since this is an element i want to repeat on most of my site i haven't associated the Questions template (the one above) for any node, so i guess what i'm lacking is the link between the template and the homepage node? Can templates function as "stand alone" with no nodes associated?

    Here's my structure:

    Master
       - Homepage (frontpage node uses this template)
          - Questions (no node associated with this template and no properties defined - only contains above div and macro)
       - Textpage

    I want this to work like the oldschool include file="" for ASP, where i can define an element, which i can insert whereever i want to, but only need to maintain one place.

     

  • Ernst Utvik 123 posts 235 karma points
    Dec 11, 2011 @ 11:34
    Ernst Utvik
    0

    Hi, sorry for the late reply. Our mail seems to go straight to my spam folder for some reason.

    My templates are set up just like yours but I have nodes associated with the "Questions" template.  Nodes associated with any of the parent templates of the "Questions" template will not render what you put in the "Questions" template. If you want you could probably render the content of a template using the
    <xsl:value-of select="umbraco.library:RenderTemplate($pageId, $templateId)" disable-output-escaping="yes"/>in an xslt macro.

  • MartinB 411 posts 512 karma points
    Dec 15, 2011 @ 12:33
    MartinB
    0

    Hi Ernst

    I'm just happy to get a reply :-)

    Didn't know the RenderTemplate function, nice. I'll give it a go.

    Many thanks for your kind assistance!

Please Sign in or register to post replies

Write your reply to:

Draft