查看标记我的用户?

发布于 2024-10-15 21:18:10 字数 61 浏览 3 评论 0原文

我正在使用视图和标志模块。用户可以标记用户。我可以轻松创建我标记的用户列表。但我无法与标记我的用户创建视图。

i'm using views and flags modules. Users can flag users. I could easily create a list of users i've flagged. But I cannot create a view with users, who flagged me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沧笙踏歌 2024-10-22 21:18:10

我通过一个非常简单的 Drupal 安装来尝试这个...只有 Core、Views 2 和 Flags。

事实上你可以这样做。我创建了一个名为 flag_user_test 的 Flag 和 3 个测试帐户以及管理员帐户。我使用其他测试帐户标记了管理员帐户,并能够使用用户 ID 作为参数来显示此用户列表,默认为当前登录的用户。

首先,创建用户类型(而不是节点)的视图。

接下来,您需要创建与“标记:用户标记的内容”的关系,并在该关系的设置中选择用户标记。我没有选择“仅包含已标记内容的用户”。

然后,使用“标志:内容 ID”类型创建一个参数。设置此参数以使用您在上一步中定义的“用户标记的内容”关系。我还提供了默认参数作为当前登录用户的用户 ID。

现在,只需从用户配置文件中添加所需的字段即可完成!Screenshot of User Flag View

这是导出的如果你想尝试一下的话请查看。我知道那里看起来真的很糟糕。但我不知道如何将其作为附件包含在内,所以这是我能做的最好的事情。如果有人知道如何使该代码块看起来更好,请成为我的客人。

<代码>
$视图=新视图;
$view->name = 'flag_me_view';
$view->description = '标记我的用户';
$view->标签='';
$view->view_php = '';
$view->base_table = '用户';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* 将其编辑为 true 以使默认视图最初禁用 */
$handler = $view->new_display('默认', '默认', '默认');
$handler->override_option('关系', array(
'flag_user_content_rel' =>;大批(
'标签' => '用户标记的内容',
'必需' => 0,
'标志' => 'flag_user_test',
'id'=> 'flag_user_content_rel',
'表' => '用户',
'字段' => 'flag_user_content_rel',
'覆盖' =>大批(
'按钮' => '覆盖',
),
'关系' => '没有任何',
),
));
$handler->override_option('fields', array(
'名字' =>大批(
'标签' => '姓名',
'改变' =>大批(
'alter_text'=>; 0,
'文本' => '',
'make_link'=>; 0,
'路径' => '',
'link_class' =>; '',
'替代' => '',
'前缀' => '',
'后缀' => '',
'目标' => '',
'帮助' => '',
'修剪' => 0,
'最大长度' => '',
'word_boundary'=>; 1、
'省略号' => 1、
'html'=> 0,
'strip_tags' =>; 0,
),
'空' => '',
'隐藏空' => 0,
'空_零' => 0,
'link_to_user'=>; 1、
'overwrite_anonymous' =>; 0,
'anonymous_text' =>; '',
'排除' => 0,
'id'=> '姓名',
'表' => '用户',
'字段' => '姓名',
'覆盖' =>大批(
'按钮' => '覆盖',
),
'关系' => '没有任何',
),
'图片' =>大批(
'标签' => '图片',
'改变' =>大批(
'alter_text'=>; 0,
'文本' => '',
'make_link'=>; 0,
'路径' => '',
'link_class' =>; '',
'替代' => '',
'前缀' => '',
'后缀' => '',
'目标' => '',
'帮助' => '',
'修剪' => 0,
'最大长度' => '',
'word_boundary'=>; 1、
'省略号' => 1、
'html'=> 0,
'strip_tags' =>; 0,
),
'空' => '',
'隐藏空' => 0,
'空_零' => 0,
'排除' => 0,
'id'=> '图片',
'表' => ‘用户’,
'字段' => '图片',
'覆盖' =>大批(
'按钮' => '覆盖',
),
'关系' => '没有任何',
),
));
$handler->override_option('参数', array(
'content_id'=>;大批(
'default_action'=>; '默认',
'style_plugin'=>; '默认摘要',
'样式选项' =>大批(),
'通配符' => '全部',
'通配符替换' => '全部',
'标题' => '',
'面包屑' => '',
'default_argument_type' =>; '当前用户',
'默认参数' => '',
'validate_type'=>; '没有任何',
'validate_fail'=>; '未找到',
'break_phrase' =>; 0,
'不' => 0,
'id'=> '内容id',
'表' => '标志内容',
'字段' => '内容id',
'关系' => 'flag_user_content_rel',
'validate_user_argument_type' =>; 'uid',
'validate_user_roles'=>;大批(
'2'=> 0,
),
'覆盖' =>大批(
'按钮' => '覆盖',
),
'default_options_div_prefix' =>; '',
'default_argument_fixed' =>; '',
'default_argument_user' =>; 0,
'default_argument_php' =>; '',
'validate_argument_node_type' =>;大批(
'页面' => 0,
'故事' => 0,
),
'validate_argument_node_access' =>; 0,
'validate_argument_nid_type' =>; '尼德',
'validate_argument_vocabulary' =>;大批(),
'validate_argument_type' =>; '蒂德',
'validate_argument_transform' =>; 0,
'validate_user_restrict_roles'=>; 0,
'validate_argument_node_flag_name' =>; '关系',
'validate_argument_node_flag_test'=>; '可标记',
'validate_argument_node_flag_id_type' =>; 'ID',
'validate_argument_user_flag_name' =>; '关系',
'validate_argument_user_flag_test'=>; '可标记',
'validate_argument_user_flag_id_type'=>; 'ID',
'validate_argument_php' =>; '',
),
));
$handler->override_option('过滤器', array(
'标记' =>大批(
'操作员' => '=',
'值' => '1',
'组' => '0',
'暴露' =>错误的,
'暴露' =>大批(
'操作员' =>错误的,
'标签' => '',
),
'id'=> ‘标记’,
'表' => '标志内容',
'字段' => ‘标记’,
'关系' => 'flag_user_content_rel',
'覆盖' =>大批(
'按钮' => '覆盖',
),
),
));
$handler->override_option('access', array(
'类型' => '没有任何',
));
$handler->override_option('缓存', array(
'类型' => '没有任何',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('路径', '标记');
$handler->override_option('菜单', array(
'类型' => '没有任何',
'标题' => '',
'描述' => '',
'重量' => 0,
'名字' => '导航',
));
$handler->override_option('tab_options', array(
'类型' => '没有任何',
'标题' => '',
'描述' => '',
'重量' => 0,
'名字' => '导航',
));

I tried this out with a very simply Drupal install... just Core, Views 2 and Flags.

You can in fact do this. I created a Flag called flag_user_test and 3 test accounts plus admin. I flagged the admin account using the other test accounts and was able to get this list of users to display using the user id as an argument, defaulting to currently logged in user.

First, create the view to be of type User (not Node).

Next, you need to create a relationship with "Flags: User's flagged content" and select the user flag on the settings for the relationship. I did not select "Include only users who have flagged content".

Then, create an Argument using the "Flags: Content ID" type. Set this argument to use the "user flagged content" relationship you defined in the last step. I also provided the default argument to be the User ID of the currently logged in user.

Now just add the fields you want from the user profile and your done!Screenshot of User Flag View

And here's an export of the view if you want to try it out. It looks really awful right there I know. But I don't know how to include it as an attachment, so that's the best I can do. If anyone knows how to make that code block look better, be my guest.


$view = new view;
$view->name = 'flag_me_view';
$view->description = 'User\'s who flagged me';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'users';
$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(
'flag_user_content_rel' => array(
'label' => 'user flagged content',
'required' => 0,
'flag' => 'flag_user_test',
'id' => 'flag_user_content_rel',
'table' => 'users',
'field' => 'flag_user_content_rel',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'name' => array(
'label' => 'Name',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_user' => 1,
'overwrite_anonymous' => 0,
'anonymous_text' => '',
'exclude' => 0,
'id' => 'name',
'table' => 'users',
'field' => 'name',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'picture' => array(
'label' => 'Picture',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'picture',
'table' => 'users',
'field' => 'picture',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'content_id' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'current_user',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'content_id',
'table' => 'flag_content',
'field' => 'content_id',
'relationship' => 'flag_user_content_rel',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'override' => array(
'button' => 'Override',
),
'default_options_div_prefix' => '',
'default_argument_fixed' => '',
'default_argument_user' => 0,
'default_argument_php' => '',
'validate_argument_node_type' => array(
'page' => 0,
'story' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(),
'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('filters', array(
'flagged' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'flagged',
'table' => 'flag_content',
'field' => 'flagged',
'relationship' => 'flag_user_content_rel',
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'flagged');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文