钩子视图查询 alterDrupal6.x(子字符串)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了钩子视图查询 alterDrupal6.x(子字符串)相关的知识,希望对你有一定的参考价值。
/** * 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 )"; } }
以上是关于钩子视图查询 alterDrupal6.x(子字符串)的主要内容,如果未能解决你的问题,请参考以下文章