4

The CiviCRM Views integration (Drupal) provides a way to create a View using data from Civi fields. Is there a way to include the output from a Civi token in the View?

The use case is that I have a token for a custom greeting that I want to include in a View.

[For this particular situation, using the email_greeting field would be enough but it does not show in the list of fields available to add to a View.]

7
  • Could you please edit your question to explain your use-case? What is your end goal?
    – Coleman
    Commented Jun 8, 2015 at 21:36
  • @Coleman - edited, hopefully that's clearer
    – Aidan
    Commented Jun 9, 2015 at 8:03
  • 1
    It sounds like the real question might be "how do I add a currently unsupported field to Views"
    – Coleman
    Commented Jun 9, 2015 at 14:45
  • @Coleman - I have created a separate question for that (civicrm.stackexchange.com/q/3120/225), and when tokens are just an existing field, it becomes just a different way of achieving the same thing. However, when tokens have more logic in them than just a simple field the question is still how to include them in a View.
    – Aidan
    Commented Jun 9, 2015 at 19:49
  • 1
    Ah, classic. But if you're writing your own custom tokens you might as well write your own views fields using the views_php module.
    – Coleman
    Commented Jun 10, 2015 at 1:23

2 Answers 2

1

I am using civicrm_entity which can pretty much expose everythign in civicrm to drupal views (and more) filter of type greeting

0

You could write a Drupal module to call hook_views_post_execute() or hook_views_pre_render(), looping through the result set and calling your token's function for each record. However, if your email greeting formula is simple, I would call hook_views_query_alter() to add it into your list of select fields, concatenating the name within your SQL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.