钩子视图查询 alterDrupal6.x(子字符串)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了钩子视图查询 alterDrupal6.x(子字符串)相关的知识,希望对你有一定的参考价值。

  1. /**
  2. * Implementation of hook_views_query_alter().
  3. */
  4. function local_views_query_alter(&$view, &$query) {
  5. if ($view->name == 'our_partners' && $view->current_display == 'page_1') {
  6. //alter the query so we actually select the results with the surname begining with the arg
  7. $query->where[0]['clauses'][3] = "SUBSTR(reverse(node.title), locate(' ', reverse(node.title)) - 1, 1) = '%s'";
  8. }
  9. if($view->name == 'our_people' && $view->current_display == 'page_1') {
  10. //alter the query so we actually select the results with the surname begining with the arg
  11. $query->where[0]['clauses'][2] = "SUBSTR(reverse(node.title), locate(' ', reverse(node.title)) - 1, 1) = '%s'";
  12. }
  13. if($view->name == 'our_people' && $view->current_display == 'attachment_1') {
  14. //alter the query so we actually select the results with the surname begining with the arg
  15. $query->fields['title_truncated']['field'] = "SUBSTRING( reverse( TRIM( node.title ) ) , locate( ' ', reverse( TRIM( node.title ) ) ) -1, 1 )";
  16. }
  17. if($view->name == 'our_partners' && $view->current_display == 'attachment_1') {
  18. //alter the query so we actually select the results with the surname begining with the arg
  19. $query->fields['title_truncated']['field'] = "SUBSTRING( reverse( TRIM( node.title ) ) , locate( ' ', reverse( TRIM( node.title ) ) ) -1, 1 )";
  20. }
  21. }

以上是关于钩子视图查询 alterDrupal6.x(子字符串)的主要内容,如果未能解决你的问题,请参考以下文章

如何挂钩子视图的子视图?

4.复杂一点的查询

我如何在 reactjs + typescript (钩子)中使用 useRef 将子状态值传递给父级

子查询|视图事务

从视图中删除子查询以使其成为索引视图

使用drf的序列化类实现增删改查接口