By Johnson2 on
I am using views 2. I tried doing a lot of things. I created a block and it is set on the profile page. What should I edit in views so I can let others see the comments posted by the user on the profile?
Currently it is showing all the comments of the website.
$view = new view;
$view->name = 'recent_comments_by';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'comments';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'uid' => array(
'label' => 'User',
'required' => 1,
'id' => 'uid',
'table' => 'comments',
'field' => 'uid',
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'subject' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_comment' => 1,
'exclude' => 0,
'id' => 'subject',
'table' => 'comments',
'field' => 'subject',
'relationship' => 'none',
),
'timestamp' => array(
'label' => 'Posted',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'date_format' => 'raw time ago',
'custom_date_format' => '2',
'exclude' => 0,
'id' => 'timestamp',
'table' => 'comments',
'field' => 'timestamp',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'timestamp' => array(
'order' => 'DESC',
'granularity' => 'second',
'id' => 'timestamp',
'table' => 'comments',
'field' => 'timestamp',
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'uid' => array(
'default_action' => 'ignore',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '%1\'s Recent Comments',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'uid',
'table' => 'users',
'field' => 'uid',
'relationship' => 'uid',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
'7' => 0,
'6' => 0,
'10' => 0,
'5' => 0,
'12' => 0,
'8' => 0,
'9' => 0,
'11' => 0,
'3' => 0,
'4' => 0,
),
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'anime_news' => 0,
'announcements' => 0,
'book' => 0,
'dub' => 0,
'movie' => 0,
'music' => 0,
'ova' => 0,
'page' => 0,
'promo' => 0,
'raw' => 0,
'review' => 0,
'subbed' => 0,
'upcomingeps' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'1' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_node_flag_name' => '*relationship*',
'validate_argument_node_flag_test' => 'flaggable',
'validate_argument_node_flag_id_type' => 'id',
'validate_argument_user_flag_name' => '*relationship*',
'validate_argument_user_flag_test' => 'flaggable',
'validate_argument_user_flag_id_type' => 'id',
'validate_argument_php' => '',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('title', 'Recent Comments');
$handler->override_option('style_plugin', 'grid');
$handler->override_option('style_options', array(
'grouping' => '',
'columns' => '2',
'alignment' => 'horizontal',
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
Comments
bump..
bump..
bump 2x... If you guys have
bump 2x...
If you guys have any links that will help my topic, please share it. Thank you.
bumped again...
bumped again...
In the arguments setting,
In the arguments setting, select "Provide default argument" radio button instead of "Display all values". Then next in "Default argument type", select "User ID from URL".
My Blog site: http://www.anupomgogoi.com
I cant get it to work... This
I cant get it to work... This is how the argument for "Comment: Author" is configured: http://img.skitch.com/20090520-rgdbkfknh6mq3f46raf33qky23.jpg
It returns just an empty view...
Are you using
Are you using http://drupal.org/project/content_profile module to create the profile pages? I mean, is there any separate content type for profile? If so, you need to use PHP code in "Default argument type:" to return the uid. Following are the code that you can use in the php code argument type:
$node = menu_get_object();
return $node->uid;
My Blog site: http://www.anupomgogoi.com
No I'm using the Profile
No I'm using the Profile module from core.
It's a bit strange since it works well with nodes...
Oh thanks dude... "In the
Oh thanks dude...
"In the arguments setting, select "Provide default argument" radio button instead of "Display all values". Then next in "Default argument type", select "User ID from URL"."
Worked like a charm, learned something new...
I'm looking for the same
I'm looking for the same solution. Why can't you do this? You'd think it'd be easy.
---
I have created and maintained countless Drupal-powered sites and have made heavy modifications to modules on a site-by-site basis. I am an illustrator, a game developer, and a web developer. I also stream on Twitch in my spare time.