Copied to clipboard

Flag this post as spam?

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


  • Duc Tran 10 posts 30 karma points
    Oct 04, 2010 @ 10:59
    Duc Tran
    0

    if statement for umbraco.library.GetItem in a masterpage

    Hi,

    In a masterpage, this if statement no longer works for 4.5.2

     <% if(umbraco.library.GetItem("content") != ""){ %>
       <umbraco:Macro fieldname="content" Alias="Item" runat="server"></umbraco:Macro> 
     <% } %>

    Is there anything I'm overlooking? Thanks,

     

    Thanks,

    DT

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 04, 2010 @ 11:03
    Aaron Powell
    0

    What's it doing?

    Try using string.IsNullOrEmpty rather than just checking ""

  • Duc Tran 10 posts 30 karma points
    Oct 04, 2010 @ 11:35
    Duc Tran
    0

    the result is always empty and nothing is returned

  • Eduardo 106 posts 130 karma points
    Oct 04, 2010 @ 12:53
    Eduardo
    0

    Hi Duc,

    Could you post the macro content please?

    Regards,
    Eduardo Macho

  • Duc Tran 10 posts 30 karma points
    Oct 04, 2010 @ 13:00
    Duc Tran
    0

    there is nothing in the macro, just some html

    i'll try the suggestion from slace

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 04, 2010 @ 14:16
    Dirk De Grave
    0

    Have you tried outputting the item using Response.Write(umbraco.library.GetItem("content"));

    Cheers,

    /Dirk

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 04, 2010 @ 14:19
    Dirk De Grave
    0

    And also, check the trace output using ?umbdebugshowtrace=true and see if there's any exception logged!

     

    Cheers,

    /Dirk

  • Pervez Choudhury 2 posts 22 karma points
    Oct 04, 2010 @ 14:43
    Pervez Choudhury
    0

    I've had the same problem and so have other people (http://our.umbraco.org/forum/core/41-feedback/11602-How-to-use-umbracolibraryGetItem()-in-code-behind).  The GetItem method will return the attributes of the node XML without any problem, but not any of the child elements.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 04, 2010 @ 14:49
    Dirk De Grave
    0

    @Pervez,

    It will, but not if you're using the new schema, seems to code is not updated to check for use of the new xml schema introduced in v4.5+

     

    Anyways, the solution suggested in the other thread is the way to go: use nodeFactory instead of GetItem()

     

    Cheers,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft