SoBiPro - the missing field prefix problem

SoBi Pro is great... but misses some basic features, as adding a prefix to a field (might be as simple as willing to add the "dollar" signe as prefix, and not as suffix), and the templating is powerful - but criptyc even for an average Joomla developer. Recently I had to build a site wich had a special need - to display the last 4 digits of a person's Social Security Number, in the format ***-***-1234.

Obviously, due to legal restriction, the whole SSN wasn't stored, just the last 4 digits, enough for the site owner needs. In a normal world the solution should be simple: to add a field suffix as "***-***-", and you're done!

I wish would be that simple... Neo, Trinity, please, add it to the core!!!

Until that hapens, here is my solution:

1. Set up the field

(I called it SSN - stealty, eh yell ) wich resulted  in the automatically generated fieldname "field_ssn" - note it, we will need it!

2. Add formatting code to template

In the next step I added the code to the template, more specifically to the entry/details.xls where I need it, using this code:

     <div class="spField">
          <span class="label"><b><xsl:text>SSN</xsl:text></b></span>
                <span><xsl:text>:  ***-***-</xsl:text><xsl:value-of select="entry/fields/field_ssn/data"></xsl:value-of></span>

So far, so good, I have the output in the desired format - with one problem: there is a loop in the template, wich outputs all available fields, so I had at the end 2 SSN fields, the specially formatted/prefixed one, and the plain, default output. So, an extra step was needed.

3. Prevent outputting the field by the loop

Locate in your template code the start of the loop. Will look like

<xsl:for-each select="entry/fields/*"></xsl:for-each>

Add next to it the code needed to prevent the output of out specially formatted field. this will be a bit more trickier as you expect, you need to include all of the contents of the loop in an if:

      <xsl:if test="not(self::field_ssn)"></xsl:if>

So, at the end your template code will look like:

<xsl:for-each select="entry/fields/*">
          <xsl:if test="not(self::field_ssn)">

Visit to find out more regarding Lawn Irrigation