views_vcards
Overview
This module aims to provide a vCard attachment for views in a similar way as the views built-in feeds system does. With the flexibility of views, these fields can come from a user, node or referenced entity. After assigning the fields to their vCard properties, this data can be presented in a downloadable vCard.
Basic concepts
This module is based on the way the views module builds RSS and XML feeds. By selecting several fields from a (user) entity and assigning them to specific vCard fields, a complete vCard can be constructed.
When the view contains one vCard, it is delivered as it is. When a view contains multiple vCards, they get zipped before the download starts. This also works for exposed filters.
For the 3.0.0 branch I've tried to stick as much as possible to the vCard 4.0 standard. If you however want to use the 3.0 or 2.1 standards for compatibility reasons, you are able to override the views-vcards-view-row-vcard.html.twig template and make changes where needed.
Installation
Install this module using composer to also get the right zipping library.
Configuration
- Create or edit a View showing users (any entity will do, but users make the most sense), then create a new display of type 'vCard'. In this display choose vCards for both 'Format' and 'Show'. The Show settings dialog will allow you to select which field should be used for each vCard property.
- Make sure the fields you want to use are added in the fields section,
otherwise they will not show up.
- Make sure the fields you want to use are added in the fields section,
- Views vCards offers the 'attach to' option under vCard settings, allowing this module to add a download link to another display. You can for instance set up your user list view as normal with all (exposed) filters if you require them, attach the vCard display to this and the vCard export will adapt to the set filters and provide the right vCards.
Be careful with the display of usernames or email addresses in vCards and double check who has permissions to access the view because it could lead to information disclosure.
Common pitfalls
- Since Drupal 9.2 there is a permission to allow users to view other user's email addresses. Please refer to this change record: https://www.drupal.org/node/3070293. Having the permission disabled makes that no email addresses are included in vCards. Alternatively you can choose not to use the user's system mail address and use a separate field for it instead.
- To avoid vCards with embedded images becoming very large, make sure to apply an appropriate image style to the image field.
- When you see strange characters in the generated files, please check if the field is not being output as link.
Dependencies (Drupal 7)
- Views
- Libraries API
- ZipStream 0.3.1 (make sure ZipStream.php is accessible in sites/all/libraries/zipstream/src/ZipStream.php)