Copied to clipboard

Flag this post as spam?

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


  • Vincent DeCapite 64 posts 83 karma points
    Jan 06, 2011 @ 16:35
    Vincent DeCapite
    0

    XML Print Separate Records based on user input

    Hi There,

    I am hoping I can get some help with this question I have... We have a page on our website that lists contacts that people can access either by flash or by clicking a printable version button to print out the list.. What my question is, is there anyway for a user to just print one contact instead of the whole entire list?

    The templates I am using for this are below:

    DistrubutorsPrint.XSLT

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
     <!ENTITY nbsp "&#x00A0;">
        <!ENTITY country "data [@alias = 'distributorCountry']">
    ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:wsc.library="urn:wsc.library"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib wsc.library ">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:for-each select="$currentPage/node [@nodeTypeAlias = 'Distributor']">
     <xsl:sort select="&country;" order="ascending" />
        <xsl:sort select="@nodeName" order="ascending"/>
       
     <xsl:variable name="country" select="&country;" />
        <xsl:if test="not(preceding-sibling::*[./&country; = $country])">
            <h2><xsl:value-of select="$country"/></h2>
        </xsl:if>
    <strong><xsl:value-of select="@nodeName" /></strong>
        <table>
         <!--
            <tr>
             <td><strong>Country: </strong></td>
                <td>
                    <xsl:call-template name="value">
                        <xsl:with-param name="value" select="data [@alias = 'distributorCountry']" />
                    </xsl:call-template>               
                </td>
            </tr>
            -->
            <tr>
                <td><strong>Phone: </strong></td>
                <td>
                    <xsl:call-template name="value">
                        <xsl:with-param name="value" select="data [@alias = 'distributorPhone']" />
                    </xsl:call-template>               
                </td>
            </tr>           
            <tr>
                <td><strong>Fax: </strong></td>
                <td>
                    <xsl:call-template name="value">
                        <xsl:with-param name="value" select="data [@alias = 'distributorFax']" />
                    </xsl:call-template>               
                </td>
            </tr>           
            <tr>
                <td><strong>Email: </strong></td>
                <td>
                    <xsl:call-template name="value">
                        <xsl:with-param name="value" select="data [@alias = 'distributorEmail']" />
                    </xsl:call-template>               
                </td>
            </tr>           
            <tr>
                <td><strong>Website: </strong></td>
                <td>
                    <xsl:call-template name="value">
                        <xsl:with-param name="value" select="data [@alias = 'distributorWebsite']" />
                    </xsl:call-template>               
                </td>
            </tr>          
            <tr>
                <td><strong>Address: </strong></td>
                <td>
                    <xsl:call-template name="value">
                        <xsl:with-param name="value" select="umbraco.library:ReplaceLineBreaks(data [@alias = 'distributorAddress'])" />
                    </xsl:call-template>
                </td>
            </tr>
            <xsl:if test="data [@alias = 'distributorNotes'] != ''">
            <tr>
             <td><strong>Notes:</strong></td>
                <td><xsl:value-of select="data [@alias = 'distributorNotes']" /></td>           
            </tr>
            </xsl:if>        
        </table>
        <hr size="1" noshade="noshade" />
    </xsl:for-each>
    </xsl:template>
    <xsl:template name="value">
     <xsl:param name="value" />
       
        <xsl:choose>
         <xsl:when test="$value = ''">
             <xsl:text>n/a</xsl:text>
            </xsl:when>
            <xsl:otherwise>
             <xsl:value-of select="$value" disable-output-escaping="yes" />
            </xsl:otherwise>
        </xsl:choose>
       
    </xsl:template>
    </xsl:stylesheet>

     

     DistrubutorsXML.XSLT

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib ">
    <xsl:output method="xml" omit-xml-declaration="no"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:value-of select="umbraco.library:ChangeContentType('text/xml')"/>
    <xsl:variable name="countries" select="umbraco.library:GetXmlDocument('/inc/countries.xml', 'False')" />
    <distributors>
     <xsl:for-each select="$currentPage/node [@nodeTypeAlias = 'Distributor']">
         <xsl:variable name="country" select="data [@alias = 'distributorCountry']" />
         <xsl:variable name="flag" select="$countries//country [@name = $country]" />
          <distributor name="{@nodeName}">
           
             <xsl:attribute name="phone">
                 <xsl:call-template name="value">
                     <xsl:with-param name="value" select="data [@alias = 'distributorPhone']" />                   
                    </xsl:call-template>
                </xsl:attribute>
           
             <xsl:attribute name="fax">
                 <xsl:call-template name="value">
                     <xsl:with-param name="value" select="data [@alias = 'distributorFax']" />                   
                    </xsl:call-template>
                </xsl:attribute>
           
             <xsl:attribute name="email">
                 <xsl:call-template name="value">
                     <xsl:with-param name="value" select="data [@alias = 'distributorEmail']" />                   
                    </xsl:call-template>
                </xsl:attribute>
           
             <xsl:attribute name="address">
                 <xsl:call-template name="value">
                     <xsl:with-param name="value" select="data [@alias = 'distributorAddress']" />                   
                    </xsl:call-template>
                </xsl:attribute>
           
             <xsl:attribute name="location">
                 <xsl:call-template name="value">
                     <xsl:with-param name="value" select="umbraco.library:Replace(data [@alias = 'distributorLocation'], ' ', '')" />                   
                    </xsl:call-template>
                </xsl:attribute>
           
             <xsl:attribute name="country">
                 <xsl:call-template name="value">
                     <xsl:with-param name="value" select="$country" />                   
                    </xsl:call-template>
                </xsl:attribute>
           
             <xsl:attribute name="region">
                 <xsl:call-template name="value">
                     <xsl:with-param name="value" select="data [@alias = 'distributorRegion']" />                   
                    </xsl:call-template>
                </xsl:attribute>
           
                <xsl:attribute name="flag">
                    <xsl:if test="count($flag) &gt; 0">
                        <xsl:text>/elements/flags/</xsl:text>
                        <xsl:value-of select="$flag/@code" />
                        <xsl:text>.png</xsl:text>
                    </xsl:if>
                </xsl:attribute>
               
                <xsl:attribute name="website">
                 <xsl:variable name="website">
                        <xsl:if test="not(contains(data [@alias = 'distributorWebsite'], 'http')) and data [@alias = 'distributorWebsite'] != ''">
                            <xsl:text>http://</xsl:text>;
                        </xsl:if>
                        <xsl:value-of select="data [@alias = 'distributorWebsite']" />
        </xsl:variable>
                    <xsl:call-template name="value">
                     <xsl:with-param name="value" select="$website" />                   
                    </xsl:call-template>
                </xsl:attribute>
               
             <xsl:attribute name="notes">
                 <xsl:value-of select="data [@alias = 'distributorNotes']" />                   
                </xsl:attribute>
           
            </distributor>
        </xsl:for-each>
    </distributors>
    </xsl:template>
    <xsl:template name="value">
     <xsl:param name="value" />
     <xsl:choose>
         <xsl:when test="$value = ''">
             <xsl:text>n/a</xsl:text>
            </xsl:when>
            <xsl:otherwise>
             <xsl:value-of select="$value" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>
  • Sean Mooney 131 posts 158 karma points c-trib
    Jan 06, 2011 @ 17:35
    Sean Mooney
    0

    Vince,

    The easiest solution is to create a new template for a single contact, then on the print or flash page link to the single contact template and print that.

    You could also use some jQuery magic to remove the ones that you don't want to print.

    -Sean

Please Sign in or register to post replies

Write your reply to:

Draft