Last active
March 24, 2016 10:51
-
-
Save steffenr/fc669ca3fdd10bb96bfb to your computer and use it in GitHub Desktop.
Create link with attributes in Drupal 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$link_url = Url::fromRoute('node.add', array('node_type' => $content_type)); | |
$link_url->setOptions(array( | |
'attributes' => array( | |
'class' => array('button') | |
), | |
'query' => \Drupal::destination()->getAsArray(), | |
)); | |
$link_text = t('Add !content_type content', array('!content_type' => ucfirst($content_type))); | |
// Build link | |
$link = \Drupal::l($link_text, $link_url); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment