I would like to create an alphabetical glossary of records from CiviCRM based on last name. The "last name" argument does not include a glossary option. Is there a way to add this in? Where is the code for creating a glossary in views, perhaps I can modify they Civi fields views integration.

Thanks,
Maria

Comments

dawehner’s picture

It comes from views_handler_argument_string. So CiviCRM would just have to extend views_handler_argument_string and all would be fine :)

mariagwyn’s picture

Sigh ... I figured out where it was after I posted, now I just need to figure out how to extend. Tips welcome...

dawehner’s picture

can you paste the hook_views_data from civicrm?

mariagwyn’s picture

dereine - sorry, was out of town.

not sure what you are referring to with this...

m

esmerel’s picture

Status: Active » Closed (fixed)

General closing of issues with no activity for 6 months - looks like original issue was dealt with

evelien’s picture

Status: Closed (fixed) » Active

Same problem here.
Implementation of hook_views_data can be found here:
http://svn.civicrm.org/civicrm/trunk/drupal/modules/views/civicrm.views.inc

I'm looking into the problem myself, any help from people with some more knowledge about hook_views_data is appreciated.

Evelien

dawehner’s picture

Where is the code for creating a glossary in views, perhaps I can modify they Civi fields views integration.

This part is in the argument handler. See views_handler_argument_string::summary_query

evelien’s picture

Status: Active » Needs review

For those looking for the same functionality (example tells you how to edit code for glossary mode first name, same goes for last name etc.):

You need to edit civicrm.views.inc (you can find the file at civicrm\drupal\modules\views).
Line 264, argument array, replace views_handler_argument with views_handler_argument_string.

Original code:

//FIRST NAME
    $data['civicrm_contact']['first_name'] = array(
                                                   'title' => t('First Name'),
                                                   'help' => t('First Name'),
                                                   'field' => array(
                                                                    'handler' => 'civicrm_handler_field_contact_link',
                                                                    'click sortable' => TRUE,
                                                                    ),

                                                   'argument' => array(
                                                                       'handler' => 'views_handler_argument',
                                                                       ),

                                                   'filter' => array(
                                                                     'handler' => 'views_handler_filter_string',
                                                                     'allow empty' => TRUE,
                                                                     ),

                                                   'sort' => array(
                                                                   'handler' => 'views_handler_sort',
                                                                   ),
                                                   );

New code:

//FIRST NAME
    $data['civicrm_contact']['first_name'] = array(
                                                   'title' => t('First Name'),
                                                   'help' => t('First Name'),
                                                   'field' => array(
                                                                    'handler' => 'civicrm_handler_field_contact_link',
                                                                    'click sortable' => TRUE,
                                                                    ),

                                                   'argument' => array(
                                                                       'handler' => 'views_handler_argument_string',
                                                                       ),

                                                   'filter' => array(
                                                                     'handler' => 'views_handler_filter_string',
                                                                     'allow empty' => TRUE,
                                                                     ),

                                                   'sort' => array(
                                                                   'handler' => 'views_handler_sort',
                                                                   ),
                                                   );
dawehner’s picture

Status: Needs review » Fixed

Okay so this issue is fine.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Just wanted to say #8 worked great for me. Any idea how I would implement this without edit/hacking civicrm.views.inc or is that just how it is done?
Thanks

Anonymous’s picture

Status: Closed (fixed) » Active
merlinofchaos’s picture

Status: Active » Closed (fixed)

You can use hook_views_data_alter() to change this in a module.

(That said, this is really a question about Civi, not about Views, so should be dealt with there, not here.).

Anonymous’s picture

perfect - just what I was looking for. Thanks.

danielstrum’s picture

Version: 6.x-2.6 » 7.x-3.7

I was using the module based on this issue found here:
http://forum.civicrm.org/index.php/topic,17749.0.html
with Views 3 and CiviCRM 4.1. I just upgraded to Civi 4.3.1 and this no longer works (again, glossary mode is not available on Civi Contact Views).

Has anyone else seen this issue and have you found a work-around? Thanks.

I am pasting the module code below:

function myModuleName_views_data_alter(&$data) {

//DISPLAY Name for the Contact (Full Name with Prefixes and Suffixes)
// see civicrm.views.inc around line 238
    $data['civicrm_contact']['display_name'] = array(
        'title' => t('Display Name'),
        'help' => t('Full Name of the Contact with prefixes and suffixes'),
      'field' => array(
         'handler' => 'civicrm_handler_field_contact_link',
         'click sortable' => TRUE,
        ),
        'argument' => array(
         'handler' => 'views_handler_argument_string'
      ),
      'filter' => array(
         'handler' => 'views_handler_filter_string',
         'allow empty' => TRUE,
      ),
      'sort' => array(
         'handler' => 'views_handler_sort',
        )
   );
}