vcards

This is a very complicated example of what WebGUI can do with SQLReports. To export an address in vcard format, it has to meet the vcard specification exactly. When you put this in an simple template there are problems with the line breaks. Therefore everything is formatted with sql code. The sql report is then put in a snippet using an AssetProxy with mime-type: text/x-vcard. We also have to name the url of the snippet *.vcf so Internet Explorer will also understand.

The result can be downloaded here for my profile. 

The placeholder sets the username:

form:user 

The SQL code looks like:

SELECT 
'BEGIN:VCARD',
'VERSION:3.0',
CONCAT('N:',lastNameData.fieldData,';',CONCAT(firstNameData.fieldData,';;;')),
'\nFN:',firstNameData.fieldData as first,' ',lastNameData.fieldData as last,
'\nTEL;type=CELL;type=pref:',cellPhoneData.fieldData,
'\nEND:VCARD'
from
users
left join
userProfileData as firstNameData
on
users.userId=firstNameData.userId and
firstNameData.fieldName='firstName'
left join
userProfileData as lastNameData
on
users.userId=lastNameData.userId and
lastNameData.fieldName='lastName'
left join
userProfileData as cellPhoneData
on
users.userId=cellPhoneData.userId and
cellPhoneData.fieldName='cellPhone'
WHERE
users.userName=?

We put just everything from the SQL in the snippet, so the template is (note that all is on one line):

<tmpl_loop rows_loop><tmpl_loop row.field_loop><tmpl_var field.value></tmpl_loop></tmpl_loop> 
  • Debug: Query:SELECT 'BEGIN:VCARD', 'VERSION:3.0', CONCAT('N:',lastName,';',CONCAT(firstName,';;;')), '\nFN:',firstName as first,' ',lastName as last, '\nTEL;type=CELL;type=pref:',cellPhone, '\nEND:VCARD' FROM users LEFT JOIN userProfileData USING (userId) WHERE users.userName=?
  • Debug: Processed Placeholder parameters: