5

I have created a custom filter which displays some select options to the user in order to filter a view. However, I am uncertain how to add this using the hook_views_data() hook, being that the table which the filter is being applied to is a CCK table called content_type_sm_mention.

Currently I have the following, which I am not sure is right. What is missing?

function smd_views_data()
{
    $data = array();
    $data['content_type_sm_mention']['sentiment'] = array(
      'title' => t('Sentiment'),
      'help' => t('Filter by mention sentiment.'),
      'real field' => 'field_mention_sentiment_value',
      'group' => t('Content'),
      'filter' => array(
        'handler' => 'views_handler_filter_sentiment',
      ),
    );
    return $data;
}
function smd_views_handlers() {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'smd') . '/includes/views',
    ),
    'handlers' => array(
      'views_handler_filter_sentiment' => array(
        'parent' => 'views_handler_filter',
      ),
    ),
  );
}

2 Answers 2

1

To find out what is missing, implement hook_views_data_alter() and dsm($data) in the function to find the right path for your field.

0

I would look at content_views_data() in the cck module to see if you can figure out what it is returning.

2
  • If he is asking is probably because he did and he could not figure it out. Why don't you explain what he is doing in his example instead? Mar 25, 2011 at 10:24
  • @lordg I am in the same position as you... Mar 25, 2011 at 10:24

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.