Copied to clipboard

Flag this post as spam?

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


  • Steve Johnston 6 posts 26 karma points
    Jul 17, 2010 @ 23:28
    Steve Johnston
    0

    GetItem() in Umbraco 4.5

    I had the following code in a template in Umbraco 4.0.4.2, and it was working:

    <%=umbraco.library.GetItem("hp_featuredproduct_02_img")%>
    I just upgraded to Umbraco 4.5, and the same code does not seem to be working.  I can get the value using an umbraco:Item tag, as follows:

    <umbraco:Item field="hp_featuredproduct_02_img" runat="server"></umbraco:Item>

    but I need to use the <%= %> syntax, so I can use it to set an html tag attribute.  Any idea why GetItem is not working?

    Thanks,

    Steve

     

     

  • Steve Johnston 6 posts 26 karma points
    Jul 19, 2010 @ 05:15
    Steve Johnston
    0

    After some experimenting, I realized that in umbraco 4.5, I can now use <umbraco:Item field="hp_featuredproduct_02_img" runat="server"></umbraco:Item> even for html tag attributes. 

    So, the following works fine for me in 4.5: <img src="<umbraco:Item field="hp_featuredproduct_02_img" runat="server"></umbraco:Item>" />

    and there's no need to use <%=umbraco.library.GetItem("hp_featuredproduct_02_img")%> in an html attribute.

    I don't know if this is due to a change in functionality from 4.0.4.2 to 4.5, or if it was just something strange on my computer.  At any rate, I'm happy now.

     

Please Sign in or register to post replies

Write your reply to:

Draft