title: Drupal - Views. Setting a filter programmatically
body: <p>I hope this is not a stupid question I have been searching for most of the day!</p>
  
  <p>I have a Content Type (Documents) which simply contains a title, file and a category. The category value is required and is 'powered' by Taxonomy.</p>
  
  <p>I now wish to create a view which will display these documents grouped and titled by the taxonomy term.</p>
  
  <p>Using my limited Drupal knowledge I intent to iterate through the relevant terms IDs (using <code>taxonomy_get_tree($vid)</code>) and then render each view accordingly. </p>
  
  <p>To do this I have been hoping to use this snippet.</p>
  
  <pre><code>view = views_get_view('documents');
  
  $view-&gt;set_display($display_id);
  
  $filter = $view-&gt;get_item($display_id, 'filter', 'field_dl_category');
  
  $filter['value']['value'] = $filter_value;
  
  $view-&gt;set_item($display_id, 'filter', 'field_dl_category', $filter);
  
  $viewsoutput = $view-&gt;render();
  </code></pre>
  
  <p>But this is not working; when I query the value of the <code>$filter</code> <code>($view-&gt;get_item($display_id, 'filter', 'field_dl_category'))</code> I get null returned.</p>
  
  <p>Might this be that my filter name is not the same as the CCK field name?</p>
  
  <p>I am using Drupal 7.</p>
  
  <p>Any help much appreciated, I am running out of ideas (and time). </p>