Links destacats

Primer de tot cal crear el tipus de contingut ‘Links destacats’. 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(
‘links_destacats’ => (object) array(
‘type’ => ‘links_destacats’,
‘name’ => ‘Links destacats’,
‘base’ => ‘node_content’,
‘module’ => ‘node’,
‘description’ => ‘LListat de links destacats que es mostraran a la columna dreta de la pàgina a les pàgines que desitjeu (per configurar-ho, aneu a Estructura >blocs : Block per als links destacats)’,
‘help’ => ”,
‘has_title’ => ‘1’,
‘title_label’ => ‘Títol’,
‘custom’ => ‘1’,
‘modified’ => ‘1’,
‘locked’ => ‘0’,
‘disabled’ => ‘0’,
‘orig_type’ => ‘links_destacats’,
‘disabled_changed’ => FALSE,
‘bc_entity_type’ => ‘node’,
),
),
‘fields’ => array(
‘field_link_destacat_dreta’ => array(
‘translatable’ => ‘0’,
‘entity_types’ => array(),
‘settings’ => array(
‘attributes’ => array(
‘target’ => ‘default’,
‘class’ => ”,
‘rel’ => ”,
),
‘url’ => 0,
‘title’ => ‘optional’,
‘title_value’ => ”,
‘title_maxlength’ => 128,
‘enable_tokens’ => 1,
‘display’ => array(
‘url_cutoff’ => 80,
),
),
‘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_link_destacat_dreta’ => array(
‘url’ => ‘field_link_destacat_dreta_url’,
‘title’ => ‘field_link_destacat_dreta_title’,
‘attributes’ => ‘field_link_destacat_dreta_attributes’,
),
),
‘FIELD_LOAD_REVISION’ => array(
‘field_revision_field_link_destacat_dreta’ => array(
‘url’ => ‘field_link_destacat_dreta_url’,
‘title’ => ‘field_link_destacat_dreta_title’,
‘attributes’ => ‘field_link_destacat_dreta_attributes’,
),
),
),
),
),
‘foreign keys’ => array(),
‘indexes’ => array(),
‘field_name’ => ‘field_link_destacat_dreta’,
‘type’ => ‘link_field’,
‘module’ => ‘link’,
‘active’ => ‘1’,
‘locked’ => ‘0’,
‘cardinality’ => ‘1’,
‘deleted’ => ‘0’,
‘columns’ => array(
‘url’ => array(
‘type’ => ‘varchar’,
‘length’ => 2048,
‘not null’ => FALSE,
‘sortable’ => TRUE,
),
‘title’ => array(
‘type’ => ‘varchar’,
‘length’ => 255,
‘not null’ => FALSE,
‘sortable’ => TRUE,
),
‘attributes’ => array(
‘type’ => ‘text’,
‘size’ => ‘medium’,
‘not null’ => FALSE,
),
),
‘bundles’ => array(
‘node’ => array(
0 => ‘links_destacats’,
),
),
),
),
‘instances’ => array(
‘field_link_destacat_dreta’ => array(
0 => array(
‘label’ => ‘link destacat’,
‘widget’ => array(
‘weight’ => ’41’,
‘type’ => ‘link_field’,
‘module’ => ‘link’,
‘active’ => 0,
‘settings’ => array(),
),
‘settings’ => array(
‘absolute_url’ => 1,
‘validate_url’ => 1,
‘url’ => 0,
‘title’ => ‘required’,
‘title_value’ => ”,
‘title_label_use_field_label’ => 0,
‘title_maxlength’ => ‘128’,
‘enable_tokens’ => 1,
‘display’ => array(
‘url_cutoff’ => ’80’,
),
‘attributes’ => array(
‘target’ => ‘default’,
‘rel’ => ”,
‘configurable_class’ => 0,
‘class’ => ‘link-destacat-dreta’,
‘configurable_title’ => 0,
‘title’ => ”,
),
‘rel_remove’ => ‘default’,
‘user_register_form’ => FALSE,
),
‘display’ => array(
‘default’ => array(
‘label’ => ‘hidden’,
‘type’ => ‘link_default’,
‘weight’ => ‘0’,
‘settings’ => array(),
‘module’ => ‘link’,
),
‘teaser’ => array(
‘type’ => ‘hidden’,
‘label’ => ‘above’,
‘settings’ => array(),
‘weight’ => 0,
),
),
‘required’ => 0,
‘description’ => ”,
‘default_value’ => NULL,
‘field_name’ => ‘field_link_destacat_dreta’,
‘entity_type’ => ‘node’,
‘bundle’ => ‘links_destacats’,
‘deleted’ => ‘0’,
),
),
),
);

Amb això ja podeu crear enllaços destacats, però encara no es mostraran a la vostra pàgina. Per fer-ho, heu d’importar una vista. Aneu a ‘Estructura > Views > Importa’, enganxeu el següent codi a la caixa de text etiquetada com ‘Paste view code here’ i premeu ‘Importa’.

$view = new view();
$view->name = ‘links_destacats’;
$view->description = ”;
$view->tag = ‘default’;
$view->base_table = ‘node’;
$view->human_name = ‘Links destacats’;
$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’] = ‘list’;
$handler->display->display_options[‘style_options’][‘default_row_class’] = FALSE;
$handler->display->display_options[‘style_options’][‘row_class_special’] = FALSE;
$handler->display->display_options[‘row_plugin’] = ‘fields’;
$handler->display->display_options[‘row_options’][‘hide_empty’] = TRUE;
/* Camp: Contingut: link destacat */
$handler->display->display_options[‘fields’][‘field_link_destacat_dreta’][‘id’] = ‘field_link_destacat_dreta’;
$handler->display->display_options[‘fields’][‘field_link_destacat_dreta’][‘table’] = ‘field_data_field_link_destacat_dreta’;
$handler->display->display_options[‘fields’][‘field_link_destacat_dreta’][‘field’] = ‘field_link_destacat_dreta’;
$handler->display->display_options[‘fields’][‘field_link_destacat_dreta’][‘label’] = ”;
$handler->display->display_options[‘fields’][‘field_link_destacat_dreta’][‘alter’][‘alter_text’] = TRUE;
$handler->display->display_options[‘fields’][‘field_link_destacat_dreta’][‘alter’][‘text’] = ‘

‘;
$handler->display->display_options[‘fields’][‘field_link_destacat_dreta’][‘element_label_colon’] = FALSE;
$handler->display->display_options[‘fields’][‘field_link_destacat_dreta’][‘click_sort_column’] = ‘url’;
/* 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(
‘links_destacats’ => ‘links_destacats’,
);
/* 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***’,
‘und’ => ‘und’,
);

/* Display: Page */
$handler = $view->new_display(‘page’, ‘Page’, ‘page’);
$handler->display->display_options[‘path’] = ‘links-destacats’;

/* Display: Bloc per als links destacats */
$handler = $view->new_display(‘block’, ‘Bloc per als links destacats’, ‘block_1’);
$translatables[‘links_destacats’] = array(
t(‘Master’),
t(‘més’),
t(‘Aplica’),
t(‘Reinicialitza’),
t(‘Ordena per’),
t(‘Asc’),
t(‘Desc’),
t(‘

‘),
t(‘Page’),
t(‘Bloc per als links destacats’),
);

D’aquesta manera heu creat una vista que crea un bloc on es mostra els enllaços destacats. Aneu a ‘Estructura > Blocs’ i trobeu el bloc anomenat ‘View: Links destacats: Bloc per als links destacats’. 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 en les que es mostrarà aquest bloc amb els links destacats. Aneu a ‘Estructura > Blocs’ i premeu el botó ‘Configura’ que apareix al costat del bloc ‘View: Links destacats: Bloc per als links destacats’. 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 la pàgina principal.