2

I have the following XSL declaration in a custom View form for an SPList:

<xsl:element name="SharePoint:AttachmentsField">
    <xsl:attribute name="runat">server</xsl:attribute>
    <xsl:attribute name="FieldName">Attachments</xsl:attribute>
    <xsl:attribute name="ControlMode">Display</xsl:attribute>
    <xsl:attribute name="Visible">true</xsl:attribute>
    <xsl:attribute name="ItemId">
        <xsl:value-of select="@ID"/>
    </xsl:attribute>
</xsl:element>

I am not really familiar with all of XSLT (I barely use it), but it appears that this is sort of like a template as when there are multiple attachments, it outputs them all, which makes it sound like SharePoint just innately knows what to do when it sees this code seeing as there are no loops involved above.

What I need to do is filter out any attachment it returns that is named "log.txt". I am creating a fully custom form so that I can control the look of the view dialog. I am having trouble figuring out how to integrate conditional xslt instructions with this format.

0

1 Answer 1

0

Well, to post my "resolution" to this problem:

I included jQuery in the form.

I added this line: <xsl:attribute name="CssClass">attachment</xsl:attribute> to the element.

I added this jQuery code:

$(function(){
    var attachments = $(".attachment a");

    $.each(attachments, function(index, attachment){
        if ($(attachment).text() == "log.txt") {
            $(attachment).remove();
        }
    });
});

If XSLT is possible, that would be preferred, but this is how I am handling it in the meantime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.