2012-09-24 6 views
0

나는 용어집보기의 상황 별 필터에 0-9 링크를 추가해야만하는 상황이 있습니다.Drupal 7보기 where 절을 수정하는 방법?

Where 절 부분을 어떻게 변경합니까? 내가 관리

SUBSTRING(node.title, 1, :node_title) = :node_title1 

특정 값 == '0-9' 내가 hook_views_query_alter을 구현하기 위해 노력

SUBSTRING(node.title, 1, 1) =REGEXP ('[0-9]') 

경우

에 있지만

function custom_views_query_alter(&$view, &$query){ 

    $current_view=&$view; 

    switch($current_view->name){ 

    case 'glossary': 

    if($query->where[0]['conditions'][0]['value'][':node_title1']=='0-9'){ 
    $query->where[0]['conditions'][0]['field']= "SUBSTRING(node.title, 1, 1) =REGEXP ('[0-9]')"; 
    echo "YES"; 

    dpm($query->where); 
     } } } 

답변

0

작동하지 않습니다 변경해야 코드가 작동하도록하려면

function custom_views_query_alter(&$view, &$query){ 

$current_view=&$view; 
switch($current_view->name){ 

case 'glossary': 
    if($query->where){ 

    if($query->where[0]['conditions'][0]['value'][':node_title1']=="0-9"){ 
     $query->where[0]['conditions'][0]['field'] = "SUBSTRING(node.title, 1, 1) REGEXP ('[0-9]')"; 
    dpm($query->where); 
} 

} 
} 
} 
관련 문제