function recommender_default_view_template in Recommender API 7.3
Same name and namespace in other branches
- 6.3 recommender.module \recommender_default_view_template()
- 7.4 recommender.module \recommender_default_view_template()
- 7.5 recommender.module \recommender_default_view_template()
Provide default views template for helper modules. Helper modules can choose either to use "export views" or use this function to generate default views.
Parameters
$view_name:
$view_human_name:
$view_description:
$base_table either recommender_similarity or recommender_prediction.:
$base_entity_type usually either 'node' or 'users':
$base_entity_field if 'node' then 'title', if 'users' then 'name':
$argument_type either 'node' or 'current_user':
$app_name:
Return value
\view
File
- ./
recommender.module, line 222 - Providing generic recommender system algorithms.
Code
function recommender_default_view_template($view_name, $view_human_name, $view_description, $base_table, $base_entity_type, $base_entity_field, $argument_type, $app_name) {
$view = new view();
$view->name = $view_name;
$view->description = $view_description;
$view->tag = 'recommendation';
$view->base_table = $base_table;
$view->human_name = $view_human_name;
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = TRUE;
/* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view
->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = $view_human_name;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['style_plugin'] = 'list';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship */
$handler->display->display_options['relationships']['target_eid']['id'] = 'target_eid';
$handler->display->display_options['relationships']['target_eid']['table'] = $base_table;
$handler->display->display_options['relationships']['target_eid']['field'] = 'target_eid';
$handler->display->display_options['relationships']['target_eid']['required'] = 1;
$handler->display->display_options['relationships']['target_eid']['base_entity_type'] = $base_entity_type;
/* Field */
$handler->display->display_options['fields'][$base_entity_field]['id'] = $base_entity_field;
$handler->display->display_options['fields'][$base_entity_field]['table'] = $base_entity_type;
$handler->display->display_options['fields'][$base_entity_field]['field'] = $base_entity_field;
$handler->display->display_options['fields'][$base_entity_field]['relationship'] = 'target_eid';
$handler->display->display_options['fields'][$base_entity_field]['label'] = '';
$handler->display->display_options['fields'][$base_entity_field]['alter']['alter_text'] = 0;
$handler->display->display_options['fields'][$base_entity_field]['alter']['make_link'] = 0;
$handler->display->display_options['fields'][$base_entity_field]['alter']['absolute'] = 0;
$handler->display->display_options['fields'][$base_entity_field]['alter']['external'] = 0;
$handler->display->display_options['fields'][$base_entity_field]['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields'][$base_entity_field]['alter']['trim'] = 0;
$handler->display->display_options['fields'][$base_entity_field]['alter']['nl2br'] = 0;
$handler->display->display_options['fields'][$base_entity_field]['alter']['word_boundary'] = 1;
$handler->display->display_options['fields'][$base_entity_field]['alter']['ellipsis'] = 1;
$handler->display->display_options['fields'][$base_entity_field]['alter']['strip_tags'] = 0;
$handler->display->display_options['fields'][$base_entity_field]['alter']['html'] = 0;
$handler->display->display_options['fields'][$base_entity_field]['element_label_colon'] = 0;
$handler->display->display_options['fields'][$base_entity_field]['element_default_classes'] = 1;
$handler->display->display_options['fields'][$base_entity_field]['hide_empty'] = 1;
$handler->display->display_options['fields'][$base_entity_field]['empty_zero'] = 0;
if ($base_entity_type == 'node') {
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
}
elseif ($base_entity_type == 'users') {
$handler->display->display_options['fields']['name']['link_to_user'] = 1;
$handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
}
/* Sort criterion */
$handler->display->display_options['sorts']['score']['id'] = 'score';
$handler->display->display_options['sorts']['score']['table'] = $base_table;
$handler->display->display_options['sorts']['score']['field'] = 'score';
$handler->display->display_options['sorts']['score']['order'] = 'DESC';
/* Contextual filter */
$handler->display->display_options['arguments']['source_eid']['id'] = 'source_eid';
$handler->display->display_options['arguments']['source_eid']['table'] = $base_table;
$handler->display->display_options['arguments']['source_eid']['field'] = 'source_eid';
$handler->display->display_options['arguments']['source_eid']['default_action'] = 'default';
$handler->display->display_options['arguments']['source_eid']['default_argument_type'] = $argument_type;
$handler->display->display_options['arguments']['source_eid']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['source_eid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['source_eid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['source_eid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['source_eid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['source_eid']['not'] = 0;
/* Filter criterion: Recommender Application: Application name */
$handler->display->display_options['filters']['name']['id'] = 'name';
$handler->display->display_options['filters']['name']['table'] = 'recommender_app';
$handler->display->display_options['filters']['name']['field'] = 'name';
$handler->display->display_options['filters']['name']['value'] = array(
$app_name => $app_name,
);
/* Filter criterion */
$handler->display->display_options['filters']['score']['id'] = 'score';
$handler->display->display_options['filters']['score']['table'] = $base_table;
$handler->display->display_options['filters']['score']['field'] = 'score';
$handler->display->display_options['filters']['score']['operator'] = '>';
$handler->display->display_options['filters']['score']['value']['value'] = '0';
/* Display: Block */
$handler = $view
->new_display('block', 'Block', 'block');
return $view;
}