PHP code example of isaactopo / vcard-kirby3

1. Go to this page and download the library: Download isaactopo/vcard-kirby3 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

isaactopo / vcard-kirby3 example snippets




return function ($page, $pages, $site, $kirby) {

    if ($vcard = param('vcard')) {

        // Get the VCard Instance
        $vcard = $site->vcard();

        // Define Variables
        $additional = '';
        $prefix = '';
        $suffix = '';
        $lastname = '';

        // Get Your data from your Fields
        $firstname = $page->firstName();

        // add personal data
        $vcard->addName($lastname, $firstname, $additional, $prefix, $suffix);

        // add work data
        $vcard->addCompany('DaCompany');
        $vcard->addJobtitle('Web Developer');
        $vcard->addRole('Code reviewer');
        $vcard->addEmail('[email protected]');
        $vcard->addPhoneNumber(666666666, 'PREF;WORK');
        $vcard->addPhoneNumber(93888666222, 'WORK');
        $vcard->addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium');
        $vcard->addLabel('street, worktown, workpostcode Belgium');
        $vcard->addURL('http://topo.bz');

        // Add a photo
        if($img = $page->profilePicture()->toFile()){
            $img = $img->crop(400, 400, 85)->save()->root();
            $vcard->addPhoto($img);
        }

        return $vcard->download();
    }

}

// return vcard as a string
echo $vcard->getOutput();

// save vcard on disk
$vcard->setSavePath('/path/to/directory');
$vcard->save();

$vcard->setCharset('ISO-8859-1');

$firstname = utf8_decode($page->firstName());
site/controllers/profile.php