Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291228

Remove theme_more_link() and replace with #type link render arrays

$
0
0

Here is the current code for theme_more_link():

<?php
function theme_more_link($variables) {
  return
'<div class="more-link">'. l(t('More'), $variables['url'], array('attributes'=> array('title'=> $variables['title']))) . '</div>';
}
?>

In order to reproduce this with #type = link, we need to make a render array with the following structure:

<?php
$more_link
= array(
 
'#type'=> 'link',
 
'#href'=> 'admin/content',
 
'#title'=> t('More'),
 
'#attributes'=> array(
   
'#title'=> t('Show more content'),
  ),
);
$container = array(
 
'#theme'=> 'container',
 
'#children'=>  drupal_render($more_link),
 
'#attributes'=> array(
   
'class'=> array('more-link'),
  ),
);
$output = drupal_render($container);
?>

Part of #1595614: [meta] Remove all the theme functions in core that simply output a link. Replace with #type 'link' render arrays

Related:
#1939098: Convert theme_more_link() to Twig


Viewing all articles
Browse latest Browse all 291228

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>