Copied to clipboard

Flag this post as spam?

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


  • Neil 63 posts 105 karma points
    Apr 11, 2013 @ 18:27
    Neil
    0

    conditional statement in template using recursive document property

    I am trying to test a checkbox document property in my template, and want to do so recursively.  The only way I know to allow a document property to be recursive in the template is to use <umbraco:Item> tags and set recursive="true".  But, because the conditional statement is in c sharp, how do I set this up to be recursive?

    Here is what I tried that obviously doesn't work:

    <% if ((String.IsNullOrEmpty(<umbraco:Item field="footerTopShow" recursive="true" runat="server" />))) { %>
        <div id="footerTop">some content</div>
    <% } %>
  • Rich Green 2246 posts 4008 karma points
    Apr 11, 2013 @ 18:40
    Rich Green
    0

    What version of Umbraco are you using?

    Rich

  • Neil 63 posts 105 karma points
    Apr 11, 2013 @ 19:14
    Neil
    0

    4.7

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 12, 2013 @ 08:10
    Fuji Kusaka
    0

    Hi Neil,

    Here is how you could call your recursive value

    @{
       dynamic v = Model.AncestorsOrSelf().Where("footerTopShow !=\"\"").Last().footerTopShow;
       @v
    }

    Hope this helps

  • Neil 63 posts 105 karma points
    Apr 13, 2013 @ 16:07
    Neil
    0

    I'm not sure how this would work.  Where does this code go and what libraries are being used?

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 13, 2013 @ 16:34
    Fuji Kusaka
    0

    Hi Neil,

    You can simply add this razor code to your template itself.

Please Sign in or register to post replies

Write your reply to:

Draft