XsltListViewWebPart issue RRS feed

  • Question

  • I have a list (Sp 2010) that has a picture filed, and a hyperlink field.  I am trying to create a custom XsltListViewWebPart that displays the image as a clickable link to the url specified in the list's hyperlink field.  I.e. display the image on the lst, but when clicked it will follow the url specified in th ehyperlink field.

    I seem to have achieved this with this bit of xsl:

     <a href="{$url}">
          <img height="50px" width="50px" alt="No Picture">
               <xsl:attribute name="src"> <xsl:value-of select="($thisNode/@Image)" /> </xsl:attribute>

    This works perfectly in SharePoint designer, but when I save it and go view it on the actual site, none of the images show up.  As a test, I put  the value-of select="($thisNode/@Image)" in a cell by itself to see what it shows, and in SP Designer it shows me the image path (as expected).  When viewed from the actual site though, it appears blank.

    Any thoughts on what might be happening?  Why would this be different in SPD than on the actual site?  Is there anything else I am doing wrong in my xslt?

    Wednesday, July 30, 2014 7:56 PM


  • I figured it out.  The problem was that the "Image" column existed on the list, but was NOT part of the view that I was attempting the transofrmation on.  I added the filed to the view, and then added a bit of xsl to hide that column when displayed, and it works like a charm.

    I still have no answer as to why it was displaying the way I wanted in SP Designer (since the Image column was not part of the view there either), but I can only assume that SP Designer does something a little differently under the hood than when it is rendered on the actual site.  Apparently, the way things look is SP Designer is "usually" how they will look on the actual site.

    So my xsl syntax was fine, I just needed to make sure the field I was trying to reference with the "value-of select" bit was present in the view.

    Thursday, July 31, 2014 8:16 PM