This is a request I get quite often. Below is my favourite solution for it.
1 Answer
No custom code required! If you're on Drupal Views integration, which ships with CiviCRM - all that's required here are Drupal modules Views, Views PDF and installation of two libraries for the PDF generation: tcpdf and fpdi;
Here are the steps:
- First we will create a Membership tab in your Drupal
/user
screen where we will display the relevant Membership details pulled from CiviCRM:
To create this Membership Tab:
a) setup your CiviCRM - Drupal CMS integration by following the instructions here:
Administer -> System Settings -> CMS Database Integration
direct link: civicrm/admin/setting/uf?reset=1
This makes the CiviCRM tables available in your Drupal Views.
b) on the Drupal side - enable Drupal Views; and Create a new View - key elements are Relationships -> connecting CiviCRM Contact w/ Drupal user ID and Contextual Filter -> so we can create a path user/%/membership
and the Menu item: Tab: Membership
c) here is a complete Views configuration for the Page:
2. Hitting the Download Membership Certificate link produces:
To create this Certificate (a PDF download):
a) you need to download and install module: Views PDF -> which requires libraries: tcpdf and fpdi -> put them in a /libraries folder
that is accessible by your site - either sites/default/libraries
or sites/all/libraries
.
b) when installed -> add a new display in your View -> of type PDF Page. I've selected PDF fields -> in Settings you can: upload and select a background template of your choice; you can also specify an offset X and Y for each of the CiviCRM variables to position them exactly where you want them!
c) In your PDF Page View -> Note the path:
d) Now that you've made the PDF Page display: add a Field on your user/%/membership
page -> Custom text -> e.g. Download Membership Certificate. Hit Rewrite Results -> select Output this field as a link as follows:
-
Excellent write up. For newbies, you can also set this up as a Block in sidebar left so it is obvious without needing to go to the Tab– petednz - fuzion ♦Commented Sep 4, 2017 at 3:42
-
Yes add a display: block and use Drupal to position in which ever region and on whatever URL you want! Commented Sep 4, 2017 at 17:41
-
Nice write up. How can adopt this for an event participants? Thanks– TapashCommented Sep 16, 2020 at 16:39
-
Also can this be automated with civirules, so that when a participant is marked as “Attended” they would receive an email with this views link?– TapashCommented Sep 16, 2020 at 16:59