Perhaps I don't have the terminology right in that my web searches aren't pointing me to examples that apply.

I'm using views for the first time and I'm using hook_views_data to pull select fields from my table that Drupal does not know about except in this case. All the examples for views have lots more options than Ive seen.

I've successfully set up a /donation-index that pulls in every record in my table and with help I've set a link to another view /donation-detail/ [donationId] that I hope will used this parameter to filter the records found to this id.

At first I thought I would use the Contextual filter but the only field I see "email" and not donationId. I've pored over the code looking for differences between 'email' and 'donationId', even copying the email array and replacing it with another reference to the id. See below.

function manage_donations_views_data() {
  $data['GeneralDonations']['table']['group'] = t('Donations');
  $data ['GeneralDonations']['table']['base'] = array(
    'field' => 'donationId',
    'help' => t('List of recent donations'),
    'title' => t('All donations'),
    'weight' => -10,
  );


  $data['GeneralDonations']['donationForm'] = array('title' => t('Form'), 
    'help' => t('Form and type'), 
    'field' => array(
      'group' => 'donations',
      'handler' => 'views_handler_field', 
      'click sortable' => TRUE, 
      ),
      'sort' => array(
        'handler' => 'views_handler_sort', 
      'filter' => array(
        'handler' => 'views_handler_filter_string',
      ), 
      'argument' => array(
        'handler' => 'views_handler_argument_string',
      ),
    ));  
  $data['GeneralDonations']['donationId'] = array('title' => t('ID'), 
    'help' => t('id'), 
    'field' => array(
      'group' => 'donations',
      'handler' => 'views_handler_field', 
      'click sortable' => TRUE, 
      ),  
      'sort' => array(
        'handler' => 'views_handler_sort', 
      'filter' => array(
        'handler' => 'views_handler_filter_string',
      ), 
      'argument' => array(
        'handler' => 'views_handler_argument_string',
      ),
    ));
  $data['GeneralDonations']['email'] = array('title' => t('Email'), 
    'help' => t('Email'), 
    'field' => array(
      'group' => 'donations',
      'handler' => 'views_handler_field',
      ),     
      'filter' => array(
        'handler' => 'views_handler_filter_string',
      ), 
      'argument' => array(
        'handler' => 'views_handler_argument_string',
      ),
    );
    $data['GeneralDonations']['donationID'] = array('title' => t('myID'), 
    'help' => t('duplicate id'), 
    'field' => array(
      'group' => 'donations',
      'handler' => 'views_handler_field_numeric', 'click sortable' => TRUE,
      ),     
      'filter' => array(
        'handler' => 'views_handler_filter_numeric',
      ), 
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
    );

  return $data;
}

I tried to use the Filter criteria to set is equal to '%1' but no difference, just an empty set.

I hope someone can at least point me to a targeted URL where I can understand how to pull the parameter and use it to filter the result down to one record, thx, sam

Comments

sam452’s picture

It seems that putting back the views_handler_argument_string in the duplicate of the ID field is what made it finally show in the contextual filter.

    $data['GeneralDonations']['donationID'] = array('title' => t('myID'), 
    'help' => t('duplicate id'), 
    'field' => array(
      'group' => 'donations',
      'handler' => 'views_handler_field',
      ),     
      'filter' => array(
        'handler' => 'views_handler_filter_string',
      ), 
      'argument' => array(
        'handler' => 'views_handler_argument_string',
      ),
    );

I yanked out the sortable key as well. Thankfully, this is finally working as expected. Perhaps in combination with the duplicate of the ID field since it may have been used by the 'base' key, don't know, sam