Giter Club home page Giter Club logo

craft3-vcard's Introduction

Plugin Icon

vCard plugin for Craft CMS 3.x

vCard generator plugin for Craft cms 3

Requirements

This plugin requires Craft CMS 3.0.0-RC1 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require nfourtythree/vcard
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for vCard.

vCard Overview

This plugin generates a link to download a vCard from data you specify

Configuring vCard

There is only one setting for this plugin which is salt this is a string used for salting the encoded data when generating the vCard link.

This can be set by creating a vcard.php config file in the config/ directory. Please copy the config.php in the plugin for the correct layout.

Using vCard

The only thing that is really required is first name. Everything else is optional

Usage

There is a link variable available for usage in templates craft.vCard.link(options)


{% set options = {
  firstName: "Johnny",
  lastName: "Appleseed",
  additional: "Jim",
  prefix: "Mr",
  suffix: "Esq",
  company: "Apple Inc.",
  jobTitle: "Data Demo",
  email: [{ address: "[email protected]", type: "WORK" }, "[email protected]"],
  url: "http://apple.com",
  phoneNumber: ["+1 234 567 89", { number: "+9 876 543 21"}],
  photo: "http://exmaple.com/images/avatar.jpg",
  address: [{
      name: "Apple",
      extended: "Suite 1",
      street: "1 Infinte Loop",
      city: "Cupertino",
      region: "CA",
      zip: "95014",
      country: "USA",
      type: "WORK;PARCEL;POSTAL"
    },
    {
      street: "1 Yemen Road",
      zip: "1234",
      country: "Yemen",
      type: "HOME;POSTAL"
    }],
  note: "Hi there",
} %}

<a href="{{ craft.vCard.link(options) }}">Download my vCard</a>

Options

Name Type Example
firstName String Johnny
lastName String Appleseed
additional String Jim (commonly a middle name)
prefix String Mr
suffix String Esq
company String Apple Inc
jobTitle String Demo Data Guru
email String | Array See email docs
url String | Array See url docs
address String | Array See address docs
phoneNumber String | Array See phoneNumber docs
birthday String 1985-10-26 (YYYY-MM-DD format)
note String Johnny is amazing
photo String http://example.com/images/avatar.jpg (Url to image)

email

This can be specified as either a string [email protected] or an array (or even a mix!)

Name Type Example
address String [email protected]
type String type may be PREF
  email: {
    address: "[email protected]",
    type: "WORK"
  }

  // For multiple email addresses
  email: [{
      address: "[email protected]",
      type: "WORK"
    },
    {
      address: "[email protected]",
      type: "PREF;HOME"
    }]

  // Mix and match example
  email: ["[email protected]", {
      address: "[email protected]",
      type: "PREF;HOME"
    }]


url

This can be specified as either a string http://apple.com or an array (or even a mix!)

Name Type Example
address String http://apple.com
type String type may be WORK
  url: {
    address: "http://apple.com",
    type: "WORK"
  }

  // For multiple urls
  url: [{
      address: "http://apple.com",
      type: "WORK"
    },
    {
      address: "http://google.com",
      type: "HOME"
    }]

  // Mix and match example
  url: ["http://apple.com", {
      address: "http://google.com",
      type: "HOME"
    }]


phoneNumber

This can be specified as either a string +1 234 567 89 or an array (or even a mix!)

Name Type Example
number String +1 234 567 89
type String Type may be PREF
  phoneNumber: {
    number: "+1 234 567 89",
    type: "PREF;WORK;VOICE"
  }

  // For multiple phoneNumbers
  phoneNumber: [{
      number: "+1 234 567 89",
      type: "WORK"
    },
    {
      number: "+9 876 543 21",
      type: "PREF;HOME"
    }]

  // Mix and match example
  phoneNumber: ["+1 234 567 89", {
      number: "+9 876 543 21",
      type: "HOME"
    }]


address

This can be either a single or multi array

Name Type Example
name String Apple
extended String Suite 1
street String 1 Infinte Loop
city String Cupertino
region String CA
zip String 95014
country String USA
type String type may be DOM
  address: {
    name: "Apple",
    extended: "Suite 1",
    street: "1 Infinte Loop",
    city: "Cupertino",
    region: "CA",
    zip: "95014",
    country: "USA",
    type: "WORK;PARCEL;POSTAL"
  }

  // For multiple addresses
  address: [{
      name: "Apple",
      extended: "Suite 1",
      street: "1 Infinte Loop",
      city: "Cupertino",
      region: "CA",
      zip: "95014",
      country: "USA",
      type: "WORK;PARCEL;POSTAL"
    },
    {
      street: "1 Yemen Road",
      zip: "1234",
      country: "Yemen",
      type: "HOME;POSTAL"
    }]

ToDo

  • Clean up / refactor code to tidy code that was done quickly

Brought to you by Nathaniel Hammond (nfourtythree)

Thanks to

craft3-vcard's People

Contributors

nfourtythree avatar mosnar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.