Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I thought it would be nice to specify the icon and button style desired in hook_preprocess_links().
Attached is a patch that does just that.
$variables['links'][0] = array(
'title' => 'button title',
'path' => 'node/4',
'icon' => 'plus',
'button' => 'success',
'size' => 'large'
);
results in
Comment | File | Size | Author |
---|---|---|---|
#3 | 2397223-link-icon-button-size-2.patch | 1.28 KB | Jon Pugh |
Comments
Comment #1
Jon PughComment #2
Jon PughComment #3
Jon PughUpdated path to hide notices.
Comment #4
markhalliwell$link['icon']
may not exist. Needs anisset()
.This assumes the icon is glyphicon based. If
$link['icon']
is provided it should be assumed that it is the full rendered icon, either usingtheme('icon')
from Icon API or_bootstrap_icon()
when creating the links.This assumes the icon should be placed before the title. There should also be a check for
$link['icon_placement']
which has one of the two possibilities:before
orafter
.Separate issue.
This needs to be, and is, a separate issue.
Comment #5
markhalliwellThe button stuff is just simple classes, so when one is constructing the links to begin with they can just pass in the attributes themselves. The icon feature still makes sense though.
Comment #6
markhalliwellThis has been implemented as a backport of 8.x-3.x code.