Copied to clipboard

Flag this post as spam?

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


  • TrevP 3 posts 24 karma points
    Sep 29, 2010 @ 23:44
    TrevP
    0

    nested umbraco:item tags help

    Hey guys,

    I've been working with umbraco for about a week now and I'm stuck on something I was hoping could be answered here.

    I'm trying to make a page that can swap modules (essentially content properties) into different locations on the page. I have my sections that I want and in each section I have an umbraco:Item, but this is where I hit a wall.

    On my docType I have a property called sectionID_Content and its of type Textstring. This textstring holds the value of the alias of the content that I want in that section.
    Example: I have a richtext editor called bodyText and I want to put it in sectionX. I've tried

    <umbraco:Item runat="server" field="<umbraco:Item runat='server' field='bodyText' />"/>

    but this doesnt render anything at all. Is there a way I can use an umbraco:Item (Textstring) as a field for another umbraco:Item?

    Thanks,

    TrevP

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Sep 30, 2010 @ 12:21
    Lee Kelleher
    0

    Hi TrevP,

    Nesting the <umbraco:Item> controls wont work.  Probably better to use the nodeFactory API to get the content.  Here's a rough-n-ready code snippet:

    <%
        var current = umbraco.presentation.nodeFactory.Node.GetCurrent();
        var sectionId = current.GetProperty("sectionID_Content");
        var content = current.GetProperty(sectionId.Value);
    %>
    <%= content.Value %>

    Use this in your template.  The "current" variable gets the node for the current page.  "sectionId" gets the property you want. Then "content" uses the "sectionId" to get the desired property.  The last line is to output the value of "content" wherever you like.

    Cheers, Lee.

  • TrevP 3 posts 24 karma points
    Sep 30, 2010 @ 16:42
    TrevP
    0

    Thanks for the quick response Lee. Your solution works! Thanks a lot. There is one thing that's still acting weird. I used a richtext editor w/ some text:

    <p>This is the page that tells you all about my
    <strong>Umbraco</strong> test.</p>

    This shows up in the page source, but on the actual page the word Umbraco isn't bold... for some reason content.Value doesnt seem to be processing the html tags... I guess this is more of an ASP.NET question, but would you have any suggestions for correcting this?

    Thanks

    TrevP

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Sep 30, 2010 @ 16:59
    Lee Kelleher
    0

    Hi TrevP,

    I've just tried this on a default Runway install and it works fine... as in the HTML is rendered in the web-browser.

    I'm thinking it's a CSS issue? Do you know if any of the styles are setting <strong> tags to "font-weight:normal;"?

    Cheers, Lee.

    PS Don't forget to mark the solution. ;-)

  • TrevP 3 posts 24 karma points
    Sep 30, 2010 @ 17:03
    TrevP
    1

    Oh man, it was a CSS issue... thanks so much for clearing that up and again, quick response!

    Thanks for all the help Lee, very much appreciated!

    TrevP

Please Sign in or register to post replies

Write your reply to:

Draft