By tstoeckler on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Introduced in version:
8.0-alpha5
Issue links:
Description:
theme_links() now supports passing a route name, and optionally route parameters, for the links instead of href.
Drupal 7:
$links = array(
'#theme' => 'links',
'#links' => array(
'admin' => array(
'title' => t('View admin pages'),
'href' => 'admin',
),
'add_article' => array(
'title' => t('Add article'),
'href' => 'node/add/article',
),
),
);
Drupal 8:
$links = array(
'#theme' => 'links',
'#links' => array(
'admin' => array(
'title' => t('View admin pages'),
'url' => Url::fromRoute('system.admin'),
),
'add_article' => array(
'title' => t('Add article'),
'url' => Url::fromRoute('node.add', array('node_type' => 'article')),
),
),
);
Using href is still supported and is still recommended for links to external URLs.
Impacts:
Module developers
Themers