I want to add custom fields to mail templates without writing tokens. Is this possible?
If so, where can I find the entity relationship diagram for civi? Thanks,
I want to add custom fields to mail templates without writing tokens. Is this possible?
If so, where can I find the entity relationship diagram for civi? Thanks,
Yes it is possible to include custom contact fields for individuals in messages sent by CiviMail by just selecting the custom field from the list of tokens.
The help on the Insert Token widget for CiviMail explains how to do it for custom organizational contacts, and the same process works for custom household fields as well:
Custom tokens (based on custom data) can be added for organizations as well. These tokens will not be displayed in the list of available tokens, but can be added manually. The format is {contact.custom_12} – where 12 is the ID of the custom data field. To find the custom data field ID, go Administer > Customize Data & Screens > Custom Fields and click ‘edit’ on the field you want to use. Look at the URL. The last part of the URL will be an equal sign and a number (=12). The number (12 in this example) is the id of that custom field.
I have custom data fields, and they are 'multi-value' sets (e.g. employment history; John has 3 prior jobs attached to his contact profile.) These data elements are not currently available by default in CiviCRM. In order for me to be able to use these custom data elements in CiviMail, I had to write a bit of code in a Drupal Module to implement the proper 'hooks' as described at http://wiki.civicrm.org/confluence/display/CRMDOC/Customized+%28and+Custom%29+Tokens See my code at http://pastebin.com/LaDq0z82
I have just created a number of custom tokens for things like relationships, mailing lists and some multi-value custom fields. I used hooks to do so, and found the API explorer (Support -> Development -> API Explorer)very useful in the development as it helped create the key code to get the data.