Xifres destacades de la recerca

Si la vostra pàgina prové de la migració de Drupal 6 a Drupal 7, no disposeu d’aquest tipus de continguts per defecte. Podeu crear-los seguint els següents passos.

Primer de tot cal crear el tipus de contingut ‘Xifres destacades de recerca’. Per fer-ho, aneu a ‘Estructura > Tipus de contingut > Importa’, enganxeu el següent codi a la caixa de text que us apareix i feu clic al botó ‘Importa’:

$data = array(
‘bundles’ => array(
‘xifres_destacades_de_recerca’ => (object) array(
‘type’ => ‘xifres_destacades_de_recerca’,
‘name’ => ‘Xifres destacades de recerca’,
‘base’ => ‘node_content’,
‘module’ => ‘node’,
‘description’ => ‘Dades destacades de la recerca del grup. Es mostraran allà on habiliteu el block que mostra les dades (Estructura >blocs : La recerca en xifres > configura)’,
‘help’ => ”,
‘has_title’ => ‘1’,
‘title_label’ => ‘Title’,
‘custom’ => ‘1’,
‘modified’ => ‘1’,
‘locked’ => ‘0’,
‘disabled’ => ‘0’,
‘orig_type’ => ‘xifres_destacades_de_recerca’,
‘disabled_changed’ => FALSE,
‘bc_entity_type’ => ‘node’,
),
),
‘fields’ => array(
‘field_xifra’ => array(
‘translatable’ => ‘0’,
‘entity_types’ => array(),
‘settings’ => array(),
‘storage’ => array(
‘type’ => ‘field_sql_storage’,
‘settings’ => array(),
‘module’ => ‘field_sql_storage’,
‘active’ => ‘1’,
‘details’ => array(
‘sql’ => array(
‘FIELD_LOAD_CURRENT’ => array(
‘field_data_field_xifra’ => array(
‘value’ => ‘field_xifra_value’,
),
),
‘FIELD_LOAD_REVISION’ => array(
‘field_revision_field_xifra’ => array(
‘value’ => ‘field_xifra_value’,
),
),
),
),
),
‘foreign keys’ => array(),
‘indexes’ => array(),
‘field_name’ => ‘field_xifra’,
‘type’ => ‘number_integer’,
‘module’ => ‘number’,
‘active’ => ‘1’,
‘locked’ => ‘0’,
‘cardinality’ => ‘1’,
‘deleted’ => ‘0’,
‘columns’ => array(
‘value’ => array(
‘type’ => ‘int’,
‘not null’ => FALSE,
),
),
‘bundles’ => array(
‘node’ => array(
0 => ‘xifres_destacades_de_recerca’,
),
),
),
),
‘instances’ => array(
‘field_xifra’ => array(
0 => array(
‘label’ => ‘Xifra’,
‘widget’ => array(
‘weight’ => ‘1’,
‘type’ => ‘number’,
‘module’ => ‘number’,
‘active’ => 0,
‘settings’ => array(),
),
‘settings’ => array(
‘min’ => ”,
‘max’ => ”,
‘prefix’ => ”,
‘suffix’ => ”,
‘user_register_form’ => FALSE,
),
‘display’ => array(
‘default’ => array(
‘label’ => ‘above’,
‘type’ => ‘number_integer’,
‘settings’ => array(
‘thousand_separator’ => ”,
‘decimal_separator’ => ‘.’,
‘scale’ => 0,
‘prefix_suffix’ => TRUE,
),
‘module’ => ‘number’,
‘weight’ => 0,
),
‘teaser’ => array(
‘label’ => ‘hidden’,
‘type’ => ‘number_integer’,
‘weight’ => ‘0’,
‘settings’ => array(
‘thousand_separator’ => ”,
‘prefix_suffix’ => 1,
‘decimal_separator’ => ‘.’,
‘scale’ => 0,
),
‘module’ => ‘number’,
),
),
‘required’ => 0,
‘description’ => ”,
‘default_value’ => NULL,
‘field_name’ => ‘field_xifra’,
‘entity_type’ => ‘node’,
‘bundle’ => ‘xifres_destacades_de_recerca’,
‘deleted’ => ‘0’,
),
),
),
);

A partir d’aquí ja podeu crear contingut d’aquest tipus, però per visualitzar-lo cal que creeu una vista i que la mostreu en un bloc. Per tal de crear la vista, aneu a ‘Estructura > Views > Importa’, enganxeu el següent codi a la caixa de text etiquetada com a ‘Paste view code here’ i premeu ‘Importa’.

$view = new view();
$view->name = ‘xifres_de_la_recerca_vista’;
$view->description = ”;
$view->tag = ‘default’;
$view->base_table = ‘node’;
$view->human_name = ‘Xifres de la recerca : Vista’;
$view->core = 7;
$view->api_version = ‘3.0’;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially *//* Display: Master */
$handler = $view->new_display(‘default’, ‘Master’, ‘default’);
$handler->display->display_options[‘use_more_always’] = FALSE;
$handler->display->display_options[‘use_more_text’] = ‘més’;
$handler->display->display_options[‘access’][‘type’] = ‘perm’;
$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[‘exposed_form’][‘options’][‘submit_button’] = ‘Aplica’;
$handler->display->display_options[‘exposed_form’][‘options’][‘reset_button_label’] = ‘Reinicialitza’;
$handler->display->display_options[‘exposed_form’][‘options’][‘exposed_sorts_label’] = ‘Ordena per’;
$handler->display->display_options[‘pager’][‘type’] = ‘none’;
$handler->display->display_options[‘pager’][‘options’][‘offset’] = ‘0’;
$handler->display->display_options[‘style_plugin’] = ‘responsive_grid’;
$handler->display->display_options[‘style_options’][‘columns’] = ‘2’;
$handler->display->display_options[‘style_options’][‘wrapper_classes’] = ‘xifra’;
$handler->display->display_options[‘style_options’][‘column_classes’] = ‘col-xs-6 dada’;
$handler->display->display_options[‘style_options’][‘first_column_classes’] = ‘col-xs-6 dada’;
$handler->display->display_options[‘style_options’][‘last_column_classes’] = ‘col-xs-6 dada’;
$handler->display->display_options[‘style_options’][‘row_classes’] = ‘row’;
$handler->display->display_options[‘style_options’][‘first_row_classes’] = ‘row’;
$handler->display->display_options[‘style_options’][‘last_row_classes’] = ‘row’;
$handler->display->display_options[‘row_plugin’] = ‘fields’;
$handler->display->display_options[‘row_options’][‘hide_empty’] = TRUE;
/* Camp: Contingut: Xifra */
$handler->display->display_options[‘fields’][‘field_xifra’][‘id’] = ‘field_xifra’;
$handler->display->display_options[‘fields’][‘field_xifra’][‘table’] = ‘field_data_field_xifra’;
$handler->display->display_options[‘fields’][‘field_xifra’][‘field’] = ‘field_xifra’;
$handler->display->display_options[‘fields’][‘field_xifra’][‘label’] = ”;
$handler->display->display_options[‘fields’][‘field_xifra’][‘element_type’] = ‘div’;
$handler->display->display_options[‘fields’][‘field_xifra’][‘element_class’] = ‘xifra-num’;
$handler->display->display_options[‘fields’][‘field_xifra’][‘element_label_colon’] = FALSE;
$handler->display->display_options[‘fields’][‘field_xifra’][‘element_default_classes’] = FALSE;
$handler->display->display_options[‘fields’][‘field_xifra’][‘settings’] = array(
‘thousand_separator’ => ”,
‘prefix_suffix’ => 1,
);
/* Camp: Contingut: Títol */
$handler->display->display_options[‘fields’][‘title’][‘id’] = ‘title’;
$handler->display->display_options[‘fields’][‘title’][‘table’] = ‘node’;
$handler->display->display_options[‘fields’][‘title’][‘field’] = ‘title’;
$handler->display->display_options[‘fields’][‘title’][‘label’] = ”;
$handler->display->display_options[‘fields’][‘title’][‘alter’][‘word_boundary’] = FALSE;
$handler->display->display_options[‘fields’][‘title’][‘alter’][‘ellipsis’] = FALSE;
$handler->display->display_options[‘fields’][‘title’][‘element_label_type’] = ‘span’;
$handler->display->display_options[‘fields’][‘title’][‘element_label_class’] = ‘xifra-titol’;
$handler->display->display_options[‘fields’][‘title’][‘element_label_colon’] = FALSE;
$handler->display->display_options[‘fields’][‘title’][‘element_default_classes’] = FALSE;
$handler->display->display_options[‘fields’][‘title’][‘link_to_node’] = FALSE;
/* Sort criterion: Contingut: Data de publicació */
$handler->display->display_options[‘sorts’][‘created’][‘id’] = ‘created’;
$handler->display->display_options[‘sorts’][‘created’][‘table’] = ‘node’;
$handler->display->display_options[‘sorts’][‘created’][‘field’] = ‘created’;
$handler->display->display_options[‘sorts’][‘created’][‘order’] = ‘DESC’;
/* Filter criterion: Contingut: Publicat */
$handler->display->display_options[‘filters’][‘status’][‘id’] = ‘status’;
$handler->display->display_options[‘filters’][‘status’][‘table’] = ‘node’;
$handler->display->display_options[‘filters’][‘status’][‘field’] = ‘status’;
$handler->display->display_options[‘filters’][‘status’][‘value’] = 1;
$handler->display->display_options[‘filters’][‘status’][‘group’] = 1;
$handler->display->display_options[‘filters’][‘status’][‘expose’][‘operator’] = FALSE;
/* Filter criterion: Contingut: Tipus */
$handler->display->display_options[‘filters’][‘type’][‘id’] = ‘type’;
$handler->display->display_options[‘filters’][‘type’][‘table’] = ‘node’;
$handler->display->display_options[‘filters’][‘type’][‘field’] = ‘type’;
$handler->display->display_options[‘filters’][‘type’][‘value’] = array(
‘xifres_destacades_de_recerca’ => ‘xifres_destacades_de_recerca’,
);
/* Filter criterion: Contingut: Llengua */
$handler->display->display_options[‘filters’][‘language’][‘id’] = ‘language’;
$handler->display->display_options[‘filters’][‘language’][‘table’] = ‘node’;
$handler->display->display_options[‘filters’][‘language’][‘field’] = ‘language’;
$handler->display->display_options[‘filters’][‘language’][‘value’] = array(
‘***CURRENT_LANGUAGE***’ => ‘***CURRENT_LANGUAGE***’,
);/* Display: Page */
$handler = $view->new_display(‘page’, ‘Page’, ‘page’);
$handler->display->display_options[‘path’] = ‘xifres-de-la-recerca-vista’;/* Display: Bloc */
$handler = $view->new_display(‘block’, ‘Bloc’, ‘block_1’);
$handler->display->display_options[‘block_description’] = ‘La recerca en xifres’;
$translatables[‘xifres_de_la_recerca_vista’] = array(
t(‘Master’),
t(‘més’),
t(‘Aplica’),
t(‘Reinicialitza’),
t(‘Ordena per’),
t(‘Asc’),
t(‘Desc’),
t(‘Page’),
t(‘Bloc’),
t(‘La recerca en xifres’),
);

D’aquesta manera heu creat una vista que crea un bloc on es mostra les xifres de la vostra recerca. Aneu a ‘Estructura > Blocs’ i trobeu el bloc anomenat ‘La recerca en xifres’. Al selector que apareix al costat, trieu on voleu mostrar-lo (preferiblement a un lateral: ‘Primera barra lateral’ o bé ‘Second sidebar’) i deseu.

Si ho desitjeu, podeu modificar el llistat de pàgines a les que es mostrarà aquest bloc amb les xifres de la recerca. Aneu a ‘Estructura > Blocs’ i premeu el botó ‘Configura’ que apareix al costat del bloc ‘La recerca en xifres’. A l’apartat d”Opcions de visualització’, podeu triar a quines pàgines es mostrarà: A ‘Totes les pàgines excepte les llistades’ o ‘Només les pàgines llistades’. Per defecte, aquest bloc es mostra només a les pàgines que mostren les publicacions en els tres idiomes.