I am dynamically generating vCards for employees and using php to add the correct header information
Sample:
{exp:channel:entries channel="lawyer|analyst" limit="1" url_title="{segment_3}"}
BEGIN:VCARD
VERSION:3.0
REV:{entry_date}
FN:{professional_first_name} {professional_last_name}
N:{professional_last_name};{professional_first_name} {professional_initial}.
TITLE:{professional_title}
ORG: Organization
{professional_location limit="1"}
ADR;TYPE=WORK:{office}{office_address}{street};{street_2};{city} {region} {postal_code};{country}{/office_address}{/office}
LABEL;TYPE=WORK:{office}{office_address}{street}\n{street_2}\n{city} {region} {postal_code}\n{country}{/office_address}{/office}
TEL;TYPE=WORK;VOICE:{phone}
TEL;TYPE=WORK;FAX:{office}{office_fax}{/office}{/professional_location}
{professional_location offset="1" limit="1"}
ADR;TYPE=POSTAL:{office}{office_address}{street};{street_2};{city} {region} {postal_code};{country}{/office_address}{/office}
LABEL;TYPE=POSTAL:{office}{office_address}{street}\n{street_2}\n{city} {region} {postal_code}\n{country}{/office_address}{/office}
TEL;TYPE=POSTAL;VOICE:{phone}
TEL;TYPE=POSTAL;FAX:{office}{office_fax}{/office}
{/professional_location}
EMAIL;TYPE=internet,pref:{professional_email}
URL;TYPE=WORK: <a href="http://www.organization.com">http://www.organization.com</a>
TZ:-0400
END:VCARD
{/exp:channel:entries}
<?php header('Content-Type: text/x-vcard; charset=utf-8');header('Content-Disposition: attachment; filename="{segment_3}.vcf"'); exit(); ?>I am running into a issue when trying to do a few conditional checks within the channels entries loop - All conditional text is output as plain text within the card with the variables parsed. This lead to my messy implementation of the 2nd office address matrix utilizing the offset param as some users have a 2nd office they work out of and some do not. I also needed to change the TYPE attribute on the 2nd address to work with windows based programs (the cards work beautifully in OS X Address book, as it handles the inconstancies a bit better)
example:
{if street_2 != "" }{street_2}{/if}is output in plain text within the card as:
{if suite 112 !=""}suite 112{/if}
Some cards have users with a address that uses the street_2 field while others do not, and with no way to check this I am left with a extra line break on output.
I have tried several different approaches within EE but I am a PHP n00b so I haven’t made much progress trying to solve it that way.
Any help or insight is appreciated!