[support] How to output a user's comments?

marcob marcob at gawab.com
Wed Dec 27 12:43:48 UTC 2006


Thanks for helping once again Earl,

had the chance to try the latest Views module only today, but cannot 
make the Recent Comments view output any thing..

tryed both setting it up with a 'Author: User ID' argument, and with a 
'Node: Author is current user' filter,
but i keep getting only the empty page text back..

I attach the two views below in case you are up to assist further:

==== Argument View ====
   $view = new stdClass();
   $view->name = 'user_comments';
   $view->description = 'Display user recent comments';
   $view->access = array (
);
   $view->view_args_php = 'if ($type == \'block\' && arg(0) == \'user\' 
&& is_numeric(arg(1))) {
   $uid = arg(1);
   //$node = node_load($uid);
   $args[] = $uid;
}
return $args;';
   $view->page = TRUE;
   $view->page_title = 'commenti utente';
   $view->page_header = '';
   $view->page_header_format = '1';
   $view->page_footer = '';
   $view->page_footer_format = '1';
   $view->page_empty = 'nessun commento';
   $view->page_empty_format = '1';
   $view->page_type = 'node';
   $view->url = 'commenti';
   $view->use_pager = FALSE;
   $view->nodes_per_page = '20';
   $view->block = TRUE;
   $view->block_title = 'Commenti';
   $view->block_header = '';
   $view->block_header_format = '1';
   $view->block_footer = '';
   $view->block_footer_format = '1';
   $view->block_empty = 'nessun commento';
   $view->block_empty_format = '1';
   $view->block_type = 'list';
   $view->nodes_per_block = '10';
   $view->block_more = FALSE;
   $view->block_use_page_header = FALSE;
   $view->block_use_page_footer = FALSE;
   $view->block_use_page_empty = FALSE;
   $view->sort = array (
     array (
       'tablename' => 'comments',
       'field' => 'timestamp',
       'sortorder' => 'DESC',
       'options' => 'normal',
     ),
   );
   $view->argument = array (
     array (
       'type' => 'uid',
       'argdefault' => '1',
       'title' => '',
       'options' => '',
       'wildcard' => '',
       'wildcard_substitution' => '',
     ),
   );
   $view->field = array (
     array (
       'tablename' => 'comments',
       'field' => 'subject',
       'label' => '',
       'handler' => 'views_handler_field_commentlink_with_mark',
       'options' => 'nolink',
     ),
     array (
       'tablename' => 'comments',
       'field' => 'name',
       'label' => '',
     ),
     array (
       'tablename' => 'comments',
       'field' => 'timestamp',
       'label' => '',
       'handler' => 'views_handler_field_date_small',
     ),
   );
   $view->filter = array (
     array (
       'tablename' => 'node_comment_statistics',
       'field' => 'comment_count',
       'operator' => '>',
       'options' => '',
       'value' => '1',
     ),
     array (
       'tablename' => 'comments',
       'field' => 'status',
       'operator' => '=',
       'options' => '',
       'value' => '0',
     ),
   );
   $view->exposed_filter = array (
   );
   $view->requires = array(comments, node_comment_statistics);
   $views[$view->name] = $view;




==== Filter View ====
   $view = new stdClass();
   $view->name = 'user_comments';
   $view->description = 'Display user recent comments';
   $view->access = array (
);
   $view->view_args_php = '';
   $view->page = TRUE;
   $view->page_title = 'commenti utente';
   $view->page_header = '';
   $view->page_header_format = '1';
   $view->page_footer = '';
   $view->page_footer_format = '1';
   $view->page_empty = 'nessun commento';
   $view->page_empty_format = '1';
   $view->page_type = 'node';
   $view->url = 'commenti';
   $view->use_pager = FALSE;
   $view->nodes_per_page = '20';
   $view->block = TRUE;
   $view->block_title = 'Commenti';
   $view->block_header = '';
   $view->block_header_format = '1';
   $view->block_footer = '';
   $view->block_footer_format = '1';
   $view->block_empty = 'nessun commento';
   $view->block_empty_format = '1';
   $view->block_type = 'list';
   $view->nodes_per_block = '10';
   $view->block_more = FALSE;
   $view->block_use_page_header = FALSE;
   $view->block_use_page_footer = FALSE;
   $view->block_use_page_empty = FALSE;
   $view->sort = array (
     array (
       'tablename' => 'comments',
       'field' => 'timestamp',
       'sortorder' => 'DESC',
       'options' => 'normal',
     ),
   );
   $view->argument = array (
   );
   $view->field = array (
     array (
       'tablename' => 'comments',
       'field' => 'subject',
       'label' => '',
       'handler' => 'views_handler_field_commentlink_with_mark',
       'options' => 'nolink',
     ),
     array (
       'tablename' => 'comments',
       'field' => 'name',
       'label' => '',
     ),
     array (
       'tablename' => 'comments',
       'field' => 'timestamp',
       'label' => '',
       'handler' => 'views_handler_field_date_small',
     ),
   );
   $view->filter = array (
     array (
       'tablename' => 'node_comment_statistics',
       'field' => 'comment_count',
       'operator' => '>',
       'options' => '',
       'value' => '1',
     ),
     array (
       'tablename' => 'comments',
       'field' => 'status',
       'operator' => '=',
       'options' => '',
       'value' => '0',
     ),
     array (
       'tablename' => 'node',
       'field' => 'currentuid',
       'operator' => '=',
       'options' => '',
       'value' => '***CURRENT_USER***',
     ),
   );
   $view->exposed_filter = array (
   );
   $view->requires = array(comments, node_comment_statistics, node);
   $views[$view->name] = $view;



On 23/dic/06, at 8:41 AM, Earl Miles wrote:

> marcob wrote:
>> Hello list,
>>
>> does anyone know a quick way to output (in a block, in a page, on
>> user's page) coments submitted by each user?
>>
>> Views does not have a Type: Comment Filter, and there isn't any
>> contributed module capable of this afaik...
>>
>>
>> Thanks and have everybody  a warm Christmas
>>
>
> Grab Views 1.4-2
>
> Go to the views UI and under default views you'll see a 'recent 
> comments'
> block. 'add' that view; rename it to something else, such as 
> comments_user.
>
> Give it a 'page' type, and add a user argument (or add the 'user is 
> current
> user' filter). Use other tricks to feed it arguments if you want to 
> make it a
> block.
>
> -- 
> [ Drupal support list | http://lists.drupal.org/ ]
>



More information about the support mailing list