0

I have a view displaying a list of my taxonomy term (term name with link). How do I display the absolute URL of the terms?

This is the exported view I am using.

$view = new view();
$view->name = 'sitemap_taxonomie';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'taxonomy_term_data';
$view->human_name = 'Sitemap taxonomy';
$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['title'] = 'Sitemap taxonomy';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['use_more_text'] = 'plus';
$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'] = 'Appliquer';
$handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Réinitialiser';
$handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Trier par';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'name' => 'name',
  'nothing' => 'nothing',
  'nothing_1' => 'nothing_1',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'name' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'nothing' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'nothing_1' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* Champ: Terme de taxonomie : Nom */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['label'] = 'loc';
$handler->display->display_options['fields']['name']['link_to_taxonomy'] = TRUE;
$handler->display->display_options['fields']['name']['convert_spaces'] = TRUE;
/* Champ: Global : Texte personnalisé */
$handler->display->display_options['fields']['nothing']['id'] = 'nothing';
$handler->display->display_options['fields']['nothing']['table'] = 'views';
$handler->display->display_options['fields']['nothing']['field'] = 'nothing';
$handler->display->display_options['fields']['nothing']['label'] = 'changefreq';
$handler->display->display_options['fields']['nothing']['alter']['text'] = 'weekly';
/* Champ: Global : Texte personnalisé */
$handler->display->display_options['fields']['nothing_1']['id'] = 'nothing_1';
$handler->display->display_options['fields']['nothing_1']['table'] = 'views';
$handler->display->display_options['fields']['nothing_1']['field'] = 'nothing';
$handler->display->display_options['fields']['nothing_1']['label'] = 'priority';
$handler->display->display_options['fields']['nothing_1']['alter']['text'] = '0.8';
/* Critère de filtrage: Terme de taxonomie : Vocabulaire */
$handler->display->display_options['filters']['vid']['id'] = 'vid';
$handler->display->display_options['filters']['vid']['table'] = 'taxonomy_term_data';
$handler->display->display_options['filters']['vid']['field'] = 'vid';
$handler->display->display_options['filters']['vid']['value'] = array(
  3 => '3',
  4 => '4',
  2 => '2',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'sitemap-taxonomy';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'views_xml_style';
$handler->display->display_options['style_options']['root_element'] = 'urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
$handler->display->display_options['style_options']['top_child_object'] = 'url';
$handler->display->display_options['style_options']['plaintext_output'] = 1;
$handler->display->display_options['style_options']['header'] = '';
$handler->display->display_options['style_options']['using_views_api_mode'] = 0;
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['path'] = 'sitemap-taxonomy.xml';
$translatables['sitemap_taxonomie'] = array(
  t('Master'),
  t('Sitemap taxonomy'),
  t('plus'),
  t('Appliquer'),
  t('Réinitialiser'),
  t('Trier par'),
  t('Asc'),
  t('Desc'),
  t('loc'),
  t('changefreq'),
  t('weekly'),
  t('priority'),
  t('0.8'),
  t('Page'),
);

This is the output of the view.

enter image description here

  • There is a reason why Drupal doesn't use absolute URLs. Why would you need them, and what benefit you think to get from absolute URLs? – kiamlaluno Mar 24 '16 at 5:47
  • Hey @Mathieu, what is the status of this question? Did any answer solve your problem? Did you open a new question regarding the picture field question you posted as an answer? drupal.stackexchange.com/a/195881/57183 – Stefanos Petrakis Mar 29 '16 at 6:17
1

You need to do the following in your View:

  1. Add the following fields (if not there already), in the following order (rearrange if you must, TID must come before Name).
    • Taxonomy term: Term ID
    • Taxonomy term: Name

enter image description here

  1. Configure the TID field: exclude it from display, change the "Thousands marker" to none.

enter image description here

  1. Rewrite the Name as a link, using absolute paths and the tid.

enter image description here

Just tried this and it worked as you described:

enter image description here

| improve this answer | |
  • thank you for your explanation it works perfectly. But I would have liked that the URL is displayed instead of the name in the statement of my views. – user54067 Mar 24 '16 at 12:10
  • thank you for the detailed explanation, it works very well. – user54067 Mar 24 '16 at 22:51
0

Here is an alternative answer, following your comment

I would have liked that the URL is displayed instead of the name in the statement of my views.

  1. You need to install this contrib module => Views base url
  2. Add 2 fields (if not there) in your View and exclude them from display (will use them for rewriting): Taxonomy vocabulary: Machine name Global: Base url
  3. For the "Taxonomy term: Name": Select "Link this field to its taxonomy term page" and rewrite to this [base_url]/[machine_name]/[name]

enter image description here

Hope this is what you asked for! Here is the final result:

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy