title: Adding a custom filter to views in Drupal 7
body: <p>im using Drupal 7 and I want to add a new filter in views. </p>
  
  <p>I have a custom table "clicks" with two fields; nid and clicks_left. </p>
  
  <p>The filter should just contain a checkbox "Only display nodes with clicks left". So the filter should join node and clicks on nid..</p>
  
  <p>I have read like thousands of pages of custom filters but can't get it to work =)</p>
  
  <p>Please, could someone show me a working example so I understand?</p>
  
  <p>I have come so far that the filter is displayed under filters but what do I need to add to do the join and get the checkbox? The relevant code below:</p>
  
  <p>FILE clicks_views.inc:</p>
  
  <pre><code>function clicks_views_data() {
    $data = array();
  
    $data['clicks']['clicks_filter'] = array(
      'group' =&gt; t('Clicks'),
      'title' =&gt; t('Clicks left'),
      'help' =&gt; t('Filter any Views based on clicks left'),
      'filter' =&gt; array(
    'field' =&gt; 'clicks_left',
        'handler' =&gt; 'clicks_handler_filter',
      ),
    ); 
  
  return $data;
  }
  </code></pre>
  
  <p>FILE clicks_handler_filter.inc:</p>
  
  <pre><code>&lt;?php
    class clicks_handler_filter extends views_handler_filter {
  
      ???
  
  };
  </code></pre>
  
  <p>I know both functions are wrong ;)</p>