We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin:VCard

Development and Programming

Max Lazar's avatar
Max Lazar
337 posts
15 years ago
Max Lazar's avatar Max Lazar

Could you please try now. I create tag CLASS in parameters.

       
Christopher Kennedy's avatar
Christopher Kennedy
44 posts
15 years ago
Christopher Kennedy's avatar Christopher Kennedy

Works much better! Thanks! Now, if I want to add multiple office numbers (never mind the direct line business), do I just repeat “office_tel = “{office_number}” ” twice, with the second entry with say, “{office_number2}”?

       
Max Lazar's avatar
Max Lazar
337 posts
15 years ago
Max Lazar's avatar Max Lazar

Soon I will make v for EE2, and add more flexible parameters setting.

       
Christopher Kennedy's avatar
Christopher Kennedy
44 posts
15 years ago
Christopher Kennedy's avatar Christopher Kennedy

You are some kind of machine! It seems to be eating the main phone info. Here’s my code:

{exp:weblog:entries weblog="attorney" limit="1"}
{exp:vcard3 
display_name = "{title}" 
first_name = "{first_name}" 
last_name = "{last_name}"
title = "{prefix}"
{related_entries id="office"}
office_tel = "{office_phone}"
{/related_entries}
office_tel2 = "{direct_line}"
email1 = "{attorney_email}"
url = "http://www.pattersonsheridan.com"
company = "Patterson & Sheridan, LLP"
title = "{job_title}"
vcard_name = "{url_title}"}
{/exp:weblog:entries}

Here is what is getting returned:

BEGIN:VCARD
VERSION:3.0
N:Ackermann;Timothy;;;
FN:Timothy Ackermann
ORG:Patterson & Sheridan\, LLP;
TITLE:Associate
EMAIL;type=INTERNET;type=WORK;type=pref:[email protected]
TEL;type=WORK;type=pref:214.296.0148
URL;type=WORK;type=pref:http\://www.pattersonsheridan.com
X-ABUID:70B70F58-B47F-4A07-A585-E385433FD19F\:ABPerson
END:VCARD

Note that if I choose to remove the office_tel2 line, then the number defaults to the office number. As it stands, it is currently showing only the direct line.

       
Max Lazar's avatar
Max Lazar
337 posts
15 years ago
Max Lazar's avatar Max Lazar

but are you shore that your related_entries is works? Becouse next code and is works:

{exp:vcard3
class = "PUBLIC"
display_name = "TSawyer"
first_name = "Tom"
last_name = "Sawyer"
title = "Mister"
office_tel = "+1 914 218 9422885"
office_tel1 = "+11 914 218 9422885"
office_tel2 = "+12 914 218 9422885"
cell_tel = "+1 914 218 94885"
cell_tel1 = "+1 914 218 94885"
email1 = "[email protected]"
url = "http://MarkTwain.com"
company = "Fence Design"
title = "HR"
note = "2000-plus fence design ideas submitted"
vcard_name = "tsawye"}
       
Christopher Kennedy's avatar
Christopher Kennedy
44 posts
15 years ago
Christopher Kennedy's avatar Christopher Kennedy

Odd. Because the code works if it’s one or the other, but not both. For instance,

{exp:weblog:entries weblog="attorney" limit="1"}
{exp:vcard3 
display_name = "{title}" 
first_name = "{first_name}" 
last_name = "{last_name}"
title = "{prefix}"
{related_entries id="office"}
office_tel = "{office_phone}"
{/related_entries}
office_tel1 = "{direct_line}"
email1 = "{attorney_email}"
url = "http://www.pattersonsheridan.com"
company = "Patterson & Sheridan, LLP"
title = "{job_title}"
vcard_name = "{url_title}"}
{/exp:weblog:entries}

Yields:

BEGIN:VCARD
VERSION:3.0
N:Ackermann;Timothy;;;
FN:Timothy Ackermann
ORG:Patterson & Sheridan\, LLP;
TITLE:Associate
EMAIL;type=INTERNET;type=WORK;type=pref:[email protected]
TEL;type=WORK;type=pref:214.296.0148
URL;type=WORK;type=pref:http\://www.pattersonsheridan.com
X-ABUID:955F6C2A-DD80-47BE-B283-8001ED896DD8\:ABPerson
END:VCARD

But this:

{exp:weblog:entries weblog="attorney" limit="1"}
{exp:vcard3 
display_name = "{title}" 
first_name = "{first_name}" 
last_name = "{last_name}"
title = "{prefix}"
{related_entries id="office"}
office_tel = "{office_phone}"
{/related_entries}
email1 = "{attorney_email}"
url = "http://www.pattersonsheridan.com"
company = "Patterson & Sheridan, LLP"
title = "{job_title}"
vcard_name = "{url_title}"}
{/exp:weblog:entries}

Yields:

BEGIN:VCARD
VERSION:3.0
N:Ackermann;Timothy;;;
FN:Timothy Ackermann
ORG:Patterson & Sheridan\, LLP;
TITLE:Associate
EMAIL;type=INTERNET;type=WORK;type=pref:[email protected]
TEL;type=WORK;type=pref:214.720.2200
URL;type=WORK;type=pref:http\://www.pattersonsheridan.com
X-ABUID:5D124EE1-A380-43C1-96CA-ED89A9A24F71\:ABPerson
END:VCARD

I know the relationship is valid, as it works in the second example, but it is ignored in the first. It even happens for manual entries like this:

{exp:weblog:entries weblog="attorney" limit="1"}
{exp:vcard3 
display_name = "{title}" 
first_name = "{first_name}" 
last_name = "{last_name}"
title = "{prefix}"
office_tel = "713.555.4565"
office_tel1 = "{direct_line}"
email1 = "{attorney_email}"
url = "http://www.pattersonsheridan.com"
company = "Patterson & Sheridan, LLP"
title = "{job_title}"
vcard_name = "{url_title}"}
{/exp:weblog:entries}

Which still puts out:

BEGIN:VCARD
VERSION:3.0
N:Ackermann;Timothy;;;
FN:Timothy Ackermann
ORG:Patterson & Sheridan\, LLP;
TITLE:Associate
EMAIL;type=INTERNET;type=WORK;type=pref:[email protected]
TEL;type=WORK;type=pref:214.296.0148
URL;type=WORK;type=pref:http\://www.pattersonsheridan.com
X-ABUID:12B992E0-0981-4BD0-8F5D-4F6FFC7D425B\:ABPerson
END:VCARD

Sorry to go on ad nauseum about this; I really think this is a great plugin and helps to shave off so much guesswork of getting a vcard to properly download via MIME types, etc.

       
Max Lazar's avatar
Max Lazar
337 posts
15 years ago
Max Lazar's avatar Max Lazar

one more time…

😊

       
Christopher Kennedy's avatar
Christopher Kennedy
44 posts
15 years ago
Christopher Kennedy's avatar Christopher Kennedy

Still no luck. Even when I set the numbers to non custom fields, just hardcoded entries of “713.55.4565” and “713.568.4565”, only one entry comes through, which is always the last entry. Nothing else is output. I’m currently using office_tel and office_tel1

       
Max Lazar's avatar
Max Lazar
337 posts
15 years ago
Max Lazar's avatar Max Lazar

I think is the problem with my misunderstanding specification. Let’s try one more time and I will go to read the standards 😊

       
Christopher Kennedy's avatar
Christopher Kennedy
44 posts
15 years ago
Christopher Kennedy's avatar Christopher Kennedy

That does it, sir! I haven’t tried editing the cell, etc. information, but I assume those have all been addressed in the same manner?

       
Max Lazar's avatar
Max Lazar
337 posts
15 years ago
Max Lazar's avatar Max Lazar

Christopher, I read the vCard specification again and found that even my plugin work fine for you, but it was incorrect by standards. Previous version (0.8.3) was correct, but it possible that program which you use do not understand more that one tel number without “hack”(v 0.8.4 has not standards TEL TYPE’s like voice1, voice2 etc.). What do you use for read vcard’s?

I update plugin with specification requirement’s.

Parameters: class = “” display_name = “” first_name = “” last_name = “” additional_name = “” name_prefix = “” name_suffix = “” nickname = “” title = “” role = “” department = “” company = “” work_po_box = “” work_extended_address = “” work_address = “” work_city = “” work_state = “” work_postal_code = “” work_country = “” home_po_box = “” home_extended_address = “” home_address = “” home_city = “” home_state = “” home_postal_code = “” home_country = “” office_tel = “” office_tel1 = “” office_tel2 = “” office_tel3 = “” office_tel4 = “” home_tel = “” cell_tel = “” cell_tel2 = “” cell_tel3 = “” fax_tel = “” fax_tel1 = “” fax_tel2 = “” fax_tel3 = “” pager_tel = “” email1 = “” email2 = “” url = “” photo = “” birthday = “” timezone = “” sort_string = “” note = “” vcard_name = “”
       
Christopher Kennedy's avatar
Christopher Kennedy
44 posts
15 years ago
Christopher Kennedy's avatar Christopher Kennedy

I’m using OSX’s native Address Book function.

I do see that the function is working properly with microsoft outlook, etc. and even when I simply download the vCard, I am able to see the two phone numbers, however, when I import it into Address Book in OSX, the first number

TEL;TYPE=work,voice,pref:214.720.2200

is disappearing.

It looks fine when I download the file, and even preview it by viewing the text behind it. I see this:

BEGIN:VCARD
VERSION:3.0
REV:2009-12-16 08:55:27
FN:Timothy G. Ackermann
N:Ackermann;Timothy;;;
TITLE:Associate
ORG:Patterson & Sheridan, LLP
ADR;TYPE=work:;Suite 2650;1700 Pacific Avenue;Dallas;TX;75201;
EMAIL;TYPE=internet,pref:[email protected]
TEL;TYPE=work,voice,pref:214.720.2200
TEL;TYPE=work,voice:214.296.0148
TEL;TYPE=work,fax,pref:713.623.4846
URL;TYPE=work:http://www.pattersonsheridan.com
TZ:-0600
END:VCARD

But when I import it into Address Book, I get this:

BEGIN:VCARD
VERSION:3.0
N:Ackermann;Timothy;;;
FN:Timothy Ackermann
ORG:Patterson & Sheridan\, LLP;
TITLE:Associate
EMAIL;type=INTERNET;type=WORK;type=pref:[email protected]
TEL;type=WORK;type=pref:214.296.0148
TEL;type=WORK;type=FAX:713.623.4846
item1.ADR;type=WORK;type=pref:;;Suite 2650\n1700 Pacific Avenue;Dallas;TX;75201;
item1.X-ABADR:us
URL;type=WORK;type=pref:http\://www.pattersonsheridan.com
X-ABUID:911B6700-DE79-47C0-9FBC-8F9D3A991BE3\:ABPerson
END:VCARD
       
southland's avatar
southland
3 posts
15 years ago
southland's avatar southland

With some PHP trickery and base64 encoding I’ve got photos working on vCard for anyone that’s interested.

Just pass a url to the photo parameter, and you should be good to go.

Code snippet displayed below, and full file is attached for download.

<pre><code> if ($this->data[‘note’]) { $this->card .= "NOTE:".$this->data['note']."\r\n"; }

if ($this->data['photo']) {

    // For some reason Expression Engine was encoding the URL into entities.
    // Undo that madness
    $url = html_entity_decode($this->data['photo']);

    // Attempt to get the image
    $photo_handle = fopen&#40;$url, "r"&#41;;

    // The image exists, let's do this thing!
    if ($photo_handle) {

        // vCard requires to know the image type.  We will trust the input since this is for internal
        // use only, and base the filetype on the file's extension.
        // Only used gif and jpeg here, but could easily be extended to all valid times.
        // Valid types can be found in the document at http://74.125.93.132/search?q=cache:6_ac3IQLJSoJ:www.imc.org/pdi/vcard-21.doc+vcard+url&cd=6&hl=en&ct=clnk&gl=us&client=safari
        $extension = strtolower(pathinfo($url, PATHINFO_EXTENSION));

        $photo_type = '';
        switch ($extension)
        {
            case 'gif':
                $photo_type = 'GIF';
            case 'jpeg':
            case 'jpg':
            default:
                $photo_type = 'JPEG';
        }

        // Read the photo into a buffer
        $photo_buffer = null;
        while (!feof($photo_handle)) {
            $photo_buffer .= fgets($photo_handle, 4096);
        }
        fclose($photo_handle);

        // Encode the photo!
        $photo_encoded = base64_encode($photo_buffer);

        // Actually put it all into the VCARD
        $this->card .= "PHOTO;ENCODING=BASE64;TYPE=" . $photo_type . ":" . $photo_encoded . "\r\n";
    }
}

  $this->card .= "TZ:".$this->data['timezone']."\r\n";[/code]
       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.