Views Arguments

Events happening in the community are now at Drupal community events on www.drupal.org.
edward.ishaq-gdo's picture

hi ,
i am new to drupal , i have created a simple view to show a list of groups .
i wanted to relate this view to taxonomy, that is passed in the url.

what i did so far is :

<?php
function diary_views_tables() {
  
$tables["rc_og"] = array(

   
'name' => 'rc_og',
     
'join'=>array(
           
'left'=>array(
               
'table'=>'node',
               
'field'=>'nid'
         
),
        
'right' => array(
       
'field' => 'og_nid'
     
)
     ),
    
      
'name' => 'term_node',
     
'join'=>array(
           
'left'=>array(
               
'table'=>'node',
               
'field'=>'nid'
         
),
        
'right' => array(
       
'field' => 'nid'
     
)
     ),
    
      
'fields'=>array(
     
//"IF(rc_og.img_nid is null,'common/groups.gif',concat('files/images/',rc_og.img_nid,'-thumbnail.gif')) AS img_path"=>array(
           
'img_nid'=>array(
            
'name'=>'Picture Path',
            
//'handler'=>'diary_views_handler_field_imgNode',
              
'sortable'=>false
        
),
        
'title'=>array(
              
'name'=>'GroupTitle',
              
//'handler'=>'diary_views_handler_field_Title',
            
'sortable'=>false
        
),
        
'changed'=>array(
            
'name'=>'date changed',
            
//'handler'=>'diary_views_handler_field_Date',
             
'sortable'=>false
        
),
     /<
em>'filters' => array(
     
'name' => array(
       
'name' => t('Usernode: Name'),
       
'operator' => 'views_handler_operator_or',
       
'list' => 'views_handler_filter_username',
       
'value-type' => 'array',
       
'help' => t('This allows you to filter by a particular user. You might not find this useful if you have a lot of users.'),
      ),</
em>/
      )
  );
  return
$tables;
}

function
diary_views_default_views(){
 
$view = new stdClass();
 
$view->name = 'Fan_Group_API';
 
$view->description = 'Shows the FAN_Group Related to Taxonomy.made by Edy';
 
$view->access = array (
  );
 
$view->view_args_php = '';
 
$view->sort = array (
  );
 
$view->argument = array (
  );
 
$view->field = array (
    array (
     
'tablename' => 'n',
     
'field' => 'title',
     
'label' => 'Group Title',
    ),
    array (
     
'tablename' => 'n',
     
'field' => 'type',
     
'label' => 'type',
    ),
    array (
     
'tablename' => 'n',
     
'field' => 'changed',
     
'label' => 'date Changed',
    ),
    array (
     
'tablename' => 'rc_og',
     
'field' => 'img_nid',
     
'label' => 'img_nid',
    ),
    array (
     
'tablename' => 'term_node',
     
'field' => 'tid',
     
'label' => 'TermID',
    )
   
  );

 
$views[$view->name] = $view;
 
  return
$views;
}

/**
* Implements the hook_views_arguments
* this function should define how to filter the groups
* depending on what term you get in the URL
*
*/

function diary_views_arguments(){
 
  
$arguments['Term_ID_arg'] = array(
   
'name' => t('Term ID'),
   
'help' => 'this argument filters the list in the block',
   
'handler' => t('views_handler_arg_TermID')
  );
 
rc_die($arguments,'args');
 
  return
$arguments;
}

function
views_handler_arg_TermID($op, &$query, $argtype, $arg = '') {
//    rc_die($op,'op of views_handler_arg_TermID');
 
switch($op) {
    case
'summary':
     
$query->add_where("AND term_node.tid=".arg(0));
    
// $query->add_groupby("n.type");
     
$fieldinfo['field'] = "term_node.tid";
      return
$fieldinfo;
      break;
    case
'filter':
      
$query->add_where("AND term_node.tid=".arg(0));
      break;
    case
'link':
      return
l($query->type, "views/$arg/$query->type");
    case
'title':
      return
$query;
  }
}
?>

my problem is that i don't know when drupal calls the hook : diary_views_arguments() !

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week