Last updated October 13, 2009. Created by yurtboy on October 13, 2009.
Log in to edit this page.

I have a couple of clients who need views to show nodes ONCE even though the node might be tagged twice.
A good example would be a node type Animal
And this Animal is a Zebra.

If the Vocabulary Color is used and Mulit Select is ON then this Zebra would get TWO tags White and Black.

So for example we make a basic node view saying SHOW ALL ANIMALS and filter that is on say the Taxonomy (maybe even just on Type of Node etc) it will show TWICE.
Even if you use the No Duplicate. I followed this http://drupal.org/node/409808 to make it all work out.

Some tips here as well.

Using template.php or a module that you make just to override this you make this function.

/* the rvtcoverrides_ prefix just happens to be
*the name of the module I use for misc
* overrides if not using the template.php
*/
function rvtcoverrides_views_pre_execute(&$view) {
/* this first set message just helps me
  *find the view name to target in
  *this case eventsTEST
*/
//drupal_set_message($view->name);
if($view->name=="eventsTEST") {
  /* this next set message was for me
   * to see the query, copy it and paste it out into the hook here
   */
  //drupal_set_message($view->build_info['query']);
/* now I got the query it builds now to
  * mess with it. If you run this in mysql with out the
  * GROUP BY node.nid it shows duplicates so
  * I added that hoping it will be enough.
  * (any advice here on a better SQL would be great!)
  */
  $view->build_info['query']="SELECT DISTINCT(node.nid) AS nid, node_data_field_event_image.field_event_image_fid AS node_data_field_event_image_field_event_image_fid, node_data_field_event_image.field_event_image_list AS node_data_field_event_image_field_event_image_list, node_data_field_event_image.field_event_image_data AS node_data_field_event_image_field_event_image_data, node_data_field_event_image.delta AS node_data_field_event_image_delta, node.type AS node_type, node.vid AS node_vid, node.title AS node_title, node_data_field_date.field_date_value AS node_data_field_date_field_date_value, node_data_field_date.field_date_value2 AS node_data_field_date_field_date_value2, node_data_field_date.field_date_rrule AS node_data_field_date_field_date_rrule, node_data_field_date.delta AS node_data_field_date_delta, node_revisions.teaser AS node_revisions_teaser, node_revisions.format AS node_revisions_format, term_data.name AS term_data_name, term_data.vid AS term_data_vid, term_data.tid AS term_data_tid FROM {node} node LEFT JOIN {content_field_date} node_data_field_date ON node.vid = node_data_field_date.vid LEFT JOIN {content_field_event_image} node_data_field_event_image ON node.vid = node_data_field_event_image.vid LEFT JOIN {node_revisions} node_revisions ON node.vid = node_revisions.vid LEFT JOIN {term_node} term_node ON node.vid = term_node.vid LEFT JOIN {term_data} term_data ON term_node.tid = term_data.tid WHERE ((node.status <> 0) AND (node.type in ('%s'))) AND (DATE_FORMAT(ADDTIME(STR_TO_DATE(node_data_field_date.field_date_value, '%Y-%m-%%dT%T'), SEC_TO_TIME(-14400)), '%Y-%m-%%d') >= '2009-10-13') GROUP BY node.nid ORDER BY node_data_field_date_field_date_value ASC
";
   }
}

So the above link to the other node and these notes might make it clear how to hook a view sql

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.