What's the difference??? oneField v fieldProcessor in an XSL

Author:AnnJ
Last Updated:October 04, 2017 11:55 AM

When titan spits out (auto-generates) an xsl for you when you make a new Display Template to work with your data schema, it takes the fields and does some generic html for each field, each in their own xsl template. Some times, this is not the best html for what you want to do.

But all these these generic templates are mode=oneField. 

For example titan give you this:

    <xsl:template match="City" mode="oneField"> 
        <xsl:param name="StyleNode" />
                <span><xsl:value-of select="." disable-output-escaping="yes" /></span>
    </xsl:template>

    <xsl:template match="State" mode="oneField"> 
        <xsl:param name="StyleNode" />
                  <span><xsl:value-of select="." disable-output-escaping="yes" /></span>
    </xsl:template>

    <xsl:template match="Zip" mode="oneField"> 
        <xsl:param name="StyleNode" />
                 <span><xsl:value-of select="." disable-output-escaping="yes" /></span>
    </xsl:template>

But sometimes you want to combine the templates, because better html or display!

Yeh, so that's where fieldProcessor comes in handy.

    <xsl:template match="CityStateZip" mode="fieldProcessor"> 
        <xsl:param name="StyleNode" />
       <xsl:param name="Node" />
               <span>
                <xsl:value-of select="$Node/City" disable-output-escaping="yes" />, 
                 <xsl:value-of select="$Node/State" disable-output-escaping="yes" />
                <xsl:value-of select="$Node/Zip" disable-output-escaping="yes" />
             </span>
    </xsl:template>

top