Drupal 6.根据 CCK 配置文件字段值关联节点
我正在构建一个 drupal 6 页面视图,它需要根据用户内容配置文件中选择的值显示节点列表。
如果我没有解释清楚,请原谅,经过漫长的一天,我的大脑已经烧焦了:|
概括: 用户从其内容配置文件
创建视图页面中的节点引用字段中选择一个值,该页面显示表中的所有节点,并按配置文件中的特定值进行过滤。
用户无法从节点引用中的其他值看到节点。仅他们选择的值
User1 - 已选择高级 用户2 - 已选择中级 用户3 - 已选择*高级 user4 - 已选择中级 user5 - 选择了初学者
User1,User3 能够在表中看到彼此的节点 User2 和 User4 也是如此。用户 5 只能看到提交的一个节点
这是我一直在寻求帮助时引用的页面: 这里但是我没有使用面板模块(这应该无论如何都没关系)
我的观点:
$view = new view;
$view->name = 'AuthorSchedules';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$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('fields', array(
'field_type_nid' => array(
'label' => '',
'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_node' => 0,
'label_type' => 'custom',
'format' => 'plain',
'multiple' => array(
'group' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_type_nid',
'table' => 'node_data_field_type',
'field' => 'field_type_nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'field_center_local_nid' => array(
'label' => 'Schedule Details',
'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_node' => 0,
'label_type' => 'custom',
'format' => 'plain',
'multiple' => array(
'group' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_center_local_nid',
'table' => 'node_data_field_center_local',
'field' => 'field_center_local_nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'field_name_value' => array(
'label' => '',
'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_node' => 0,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 1,
'id' => 'field_name_value',
'table' => 'node_data_field_name',
'field' => 'field_name_value',
'relationship' => 'none',
),
'field_last_name_value' => array(
'label' => 'Trainer',
'alter' => array(
'alter_text' => 1,
'text' => '[field_name_value] [field_last_name_value] ',
'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_node' => 0,
'label_type' => 'custom',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_last_name_value',
'table' => 'node_data_field_last_name',
'field' => 'field_last_name_value',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'created' => array(
'label' => 'Post date',
'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,
'date_format' => 'custom',
'custom_date_format' => 'm-d-y',
'exclude' => 0,
'id' => 'created',
'table' => 'node',
'field' => 'created',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'field_org_ref_select_nid' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'php',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'field_org_ref_select_nid',
'table' => 'node_data_field_org_ref_select',
'field' => 'field_org_ref_select_nid',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
'4' => 0,
'6' => 0,
'5' => 0,
'3' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_fixed' => '',
'default_argument_user' => 0,
'default_argument_php' => '$userid = arg(1);
$content_profile = content_profile_load(\'profile\', $userid);
$content_profile_nid = $content_profile->nid;
$node_ref = node_load($content_profile_nid);
$refnid = $node_ref->field_org_ref_select[0][\'nid\'];
return $refnid;',
'validate_argument_node_type' => array(
'profile' => 'profile',
'center_location' => 0,
'organization' => 0,
'page' => 0,
'story' => 0,
'type' => 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_php' => '',
),
'nid' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'php',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'ignore',
'break_phrase' => 0,
'not' => 1,
'id' => 'nid',
'table' => 'node',
'field' => 'nid',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
'4' => 0,
'6' => 0,
'5' => 0,
'3' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_fixed' => '',
'default_argument_user' => 0,
'default_argument_php' => '$userid = arg(1);
$content_profile = content_profile_load(\'profile\', $userid);
$content_profile_nid = $content_profile->nid;
if($content_profile_nid) {
return $content_profile_nid;
}
return false;',
'validate_argument_node_type' => array(
'center_location' => 0,
'organization' => 0,
'page' => 0,
'profile' => 0,
'story' => 0,
'type' => 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_php' => '',
),
));
$handler->override_option('access', array(
'type' => 'role',
'role' => array(
'3' => 3,
),
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('header', '<h1>Your Training Schedules</h1>');
$handler->override_option('header_format', '2');
$handler->override_option('header_empty', 0);
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 25);
$handler->override_option('use_pager', 'mini');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'field_type_nid' => 'field_type_nid',
'field_center_local_nid' => 'field_center_local_nid',
'field_name_value' => 'field_name_value',
'field_last_name_value' => 'field_last_name_value',
'created' => 'created',
),
'info' => array(
'field_type_nid' => array(
'separator' => '',
),
'field_center_local_nid' => array(
'separator' => '',
),
'field_name_value' => array(
'sortable' => 1,
'separator' => '',
),
'field_last_name_value' => array(
'sortable' => 1,
'separator' => '',
),
'created' => array(
'sortable' => 1,
'separator' => '',
),
),
'default' => '-1',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'schedules_author');
$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',
));
如果有任何不清楚的地方请告诉我。我真的很感谢你的帮助。
I am building a drupal 6 page view which needs to display a list of nodes depending on the value selected in a user's content profile.
Excuse me if I don't explain things clearly, my brain is fried after a long day :|
Summary:
User selects a value from a node reference field in their content profile
Create view page which displays all nodes in a table, filtered by the specific value in the profile.
User can not see nodes from other values in the node reference. only their selected value
User1 - has selected advanced
User2 - has selected intermediate
User3 - has selected *advanced
user4 - has selected intermediate
user5 - has selected beginner
User1, User3 are able to see each others nodes in a table
same goes for User2 and User4. User 5 only see's one node submitted
Here is a page i have been referencing for assistance:
Here But i am not using panels module(which shouldn't matter anyways)
my view:
$view = new view;
$view->name = 'AuthorSchedules';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$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('fields', array(
'field_type_nid' => array(
'label' => '',
'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_node' => 0,
'label_type' => 'custom',
'format' => 'plain',
'multiple' => array(
'group' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_type_nid',
'table' => 'node_data_field_type',
'field' => 'field_type_nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'field_center_local_nid' => array(
'label' => 'Schedule Details',
'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_node' => 0,
'label_type' => 'custom',
'format' => 'plain',
'multiple' => array(
'group' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_center_local_nid',
'table' => 'node_data_field_center_local',
'field' => 'field_center_local_nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'field_name_value' => array(
'label' => '',
'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_node' => 0,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 1,
'id' => 'field_name_value',
'table' => 'node_data_field_name',
'field' => 'field_name_value',
'relationship' => 'none',
),
'field_last_name_value' => array(
'label' => 'Trainer',
'alter' => array(
'alter_text' => 1,
'text' => '[field_name_value] [field_last_name_value] ',
'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_node' => 0,
'label_type' => 'custom',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_last_name_value',
'table' => 'node_data_field_last_name',
'field' => 'field_last_name_value',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'created' => array(
'label' => 'Post date',
'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,
'date_format' => 'custom',
'custom_date_format' => 'm-d-y',
'exclude' => 0,
'id' => 'created',
'table' => 'node',
'field' => 'created',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'field_org_ref_select_nid' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'php',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'field_org_ref_select_nid',
'table' => 'node_data_field_org_ref_select',
'field' => 'field_org_ref_select_nid',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
'4' => 0,
'6' => 0,
'5' => 0,
'3' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_fixed' => '',
'default_argument_user' => 0,
'default_argument_php' => '$userid = arg(1);
$content_profile = content_profile_load(\'profile\', $userid);
$content_profile_nid = $content_profile->nid;
$node_ref = node_load($content_profile_nid);
$refnid = $node_ref->field_org_ref_select[0][\'nid\'];
return $refnid;',
'validate_argument_node_type' => array(
'profile' => 'profile',
'center_location' => 0,
'organization' => 0,
'page' => 0,
'story' => 0,
'type' => 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_php' => '',
),
'nid' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'php',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'ignore',
'break_phrase' => 0,
'not' => 1,
'id' => 'nid',
'table' => 'node',
'field' => 'nid',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
'4' => 0,
'6' => 0,
'5' => 0,
'3' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_fixed' => '',
'default_argument_user' => 0,
'default_argument_php' => '$userid = arg(1);
$content_profile = content_profile_load(\'profile\', $userid);
$content_profile_nid = $content_profile->nid;
if($content_profile_nid) {
return $content_profile_nid;
}
return false;',
'validate_argument_node_type' => array(
'center_location' => 0,
'organization' => 0,
'page' => 0,
'profile' => 0,
'story' => 0,
'type' => 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_php' => '',
),
));
$handler->override_option('access', array(
'type' => 'role',
'role' => array(
'3' => 3,
),
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('header', '<h1>Your Training Schedules</h1>');
$handler->override_option('header_format', '2');
$handler->override_option('header_empty', 0);
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 25);
$handler->override_option('use_pager', 'mini');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'field_type_nid' => 'field_type_nid',
'field_center_local_nid' => 'field_center_local_nid',
'field_name_value' => 'field_name_value',
'field_last_name_value' => 'field_last_name_value',
'created' => 'created',
),
'info' => array(
'field_type_nid' => array(
'separator' => '',
),
'field_center_local_nid' => array(
'separator' => '',
),
'field_name_value' => array(
'sortable' => 1,
'separator' => '',
),
'field_last_name_value' => array(
'sortable' => 1,
'separator' => '',
),
'created' => array(
'sortable' => 1,
'separator' => '',
),
),
'default' => '-1',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'schedules_author');
$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',
));
Let me know if anyhthing isn't clear. I really appreciate the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的视图应该带有一个参数,然后使用该参数进行过滤。节点参考位应该是无关的。视图需要在内容类型之间具有关系。也许这个例子能说明问题。
在我的领域,我有教授。 教授发表出版物并拥有研究兴趣。查看教授的个人资料(使用内容个人资料)时,我希望获得能够提取其所有相关出版物和研究兴趣的视图。
例如:教师简介
Publications 视图如下所示:
这在其他范例中要简单得多,并且此代码中存在很多噪音(使用 Drupal 的重要组成部分),但我希望您能有一个大概的了解。
You're using a view that should take an argument, which then uses that argument to filter. The node reference bit should be irrelevant. The view will need to have a relationship between the content types. Maybe this example will illuminate.
In my domain, I have Professors. Professors publish Publications and have Research Interests. When viewing a Professor's Profile (using Content Profile), I want to have views that pull up all of their associated Publications and Research Interests.
For example: Faculty profile
Here is what the Publications view looks like:
This is much simpler in other paradigms, and there's a lot of noise in this code (part and parcel of working with Drupal), but I hope you get a general sense.