Revision: 22259
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 7, 2010 07:09 by ReeceMarsland
Initial Code
/** * Implementation of hook_views_query_alter(). */ function local_views_query_alter(&$view, &$query) { if ($view->name == 'our_partners' && $view->current_display == 'page_1') { //alter the query so we actually select the results with the surname begining with the arg $query->where[0]['clauses'][3] = "SUBSTR(reverse(node.title), locate(' ', reverse(node.title)) - 1, 1) = '%s'"; } if($view->name == 'our_people' && $view->current_display == 'page_1') { //alter the query so we actually select the results with the surname begining with the arg $query->where[0]['clauses'][2] = "SUBSTR(reverse(node.title), locate(' ', reverse(node.title)) - 1, 1) = '%s'"; } if($view->name == 'our_people' && $view->current_display == 'attachment_1') { //alter the query so we actually select the results with the surname begining with the arg $query->fields['title_truncated']['field'] = "SUBSTRING( reverse( TRIM( node.title ) ) , locate( ' ', reverse( TRIM( node.title ) ) ) -1, 1 )"; } if($view->name == 'our_partners' && $view->current_display == 'attachment_1') { //alter the query so we actually select the results with the surname begining with the arg $query->fields['title_truncated']['field'] = "SUBSTRING( reverse( TRIM( node.title ) ) , locate( ' ', reverse( TRIM( node.title ) ) ) -1, 1 )"; } }
Initial URL
Initial Description
Initial Title
hook_views_query_alter Drupal 6.x (substring)
Initial Tags
mysql, drupal
Initial Language
PHP