【问题标题】:Drupal 7 Views 3 Fatal error: Cannot access protected property SelectQuery::$whereDrupal 7 Views 3 致命错误:无法访问受保护的属性 SelectQuery::$where
【发布时间】:2011-11-15 03:55:12
【问题描述】:

我在尝试修改 Drupal 7 Views 3 过滤器中的值时收到此错误:

Fatal error: Cannot access protected property SelectQuery::$where in /Users/joe/Sites/sdgea/docroot/sites/all/modules/custom/sdge_video/sdge_video.module on line 275

这是导致此问题的代码:

function modulename_views_pre_execute(&$view) {
  if (is_numeric($term_no)) {
        // set the filter
    $view->filter['tid']->value[$term_no] = $term_no;
        // set the query
        $view->query->where[0]['conditions'][2]['value'] = $term_no;
        // set the build info
        $view->build_info['query']->where->conditions[0]['field']->conditions[0]['field']->conditions[2]['value'] = $term_no;
        //$view->build_info['query']->where->conditions[0]['field']->conditions[0]['field']->conditions[2]['value'] = $term_no; // <-- This line specifically is causing fatality.
  }
}

可能是 D7 中某个超人物体 yada yada 的一部分。任何人都对我如何在视图 3 视图 (D7) 中修改过滤器的值有任何想法。

此外,还要求回答为什么会发生对“受保护财产”的访问。我是一名编码员。我不想保护任何东西!

提前致谢!

【问题讨论】:

    标签: drupal drupal-7 drupal-views


    【解决方案1】:

    可能有点晚了,但您可以使用 hook_views_query_alter 对其进行修改,这正是为此目的,如下所示:

    function modulename_views_query_alter(&$views,&$query){
        //...rest of the code
        $query->where[0]['conditions'][2]['value'] = $term_no;
    }
    

    【讨论】:

      猜你喜欢
      • 2012-12-28
      • 1970-01-01
      • 1970-01-01
      • 2014-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-01
      相关资源
      最近更新 更多