Skip to content

Commit

Permalink
Merge pull request #30 from Born-Digital-US/ArchiDeployment/ISSUE-169
Browse files Browse the repository at this point in the history
ArchiDeployment/ISSUE-169 --> 1.0.0-RC3
  • Loading branch information
DiegoPino authored Mar 21, 2022
2 parents 09204cf + b3e385c commit 140bd04
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions archipelago_subtheme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,32 @@ function archipelago_subtheme_preprocess_page(&$variables) {
}

}

/**
* Implements hook_preprocess_HOOK() for field.html.twig.
*
* When a field title field has a fontawesome class, create
* an <i> tag for hold the fontawesome glyph and prepend it
* to the title.
*
*/
function archipelago_subtheme_preprocess_field(&$variables) {
if($variables['field_name'] == 'node_title') {
foreach($variables['items'] as &$item) {
foreach($item['content'] as &$content) {
if(!empty($content['#context']['attributes']) && !empty($content['#context']['wrapper'])) {
/** @var Drupal\Core\Template\Attribute $attributes */
$attributes = $content['#context']['attributes']->storage();
if(!empty($attributes['class'])) {
$class = $attributes['class']->__toString();
if(strpos($class, 'fas') !== FALSE && $content['#context']['wrapper'] != 'i') {
// Running the output through t() marks it as "safe" so that the markup not be sanitized.
$content['#context']['output'] = t('<i class="' . $class . '"></i>' . $content['#context']['output']);
$content['#context']['attributes']->removeClass($class);
}
}
}
}
}
}
}

0 comments on commit 140bd04

Please sign in to comment.