I'm running Drupal 8.2.6, and an Adaptive subtheme and I am trying to modify the page title. I have created the following function in THEME.theme
function THEME_preprocess_page_title(&$variables) {
$color_title = str_ireplace('some text', 'Some <span class="ct-green">TEXT</span>', $variables['title']);
$variables['title'] = $color_title;
}
unfortunately, it's not working, at all. I've even tried just
$variables['title'] = 'Hello World';
to see if it would work, but no dice.
EDIT So the hunt goes on!
Apparently AdaptiveTheme doesn't use the page title block, it writes it into node.html.twig via field--node--title.html.twig
so far, I have edited THEME_preprocess_field__node__title(&$variables) with no luck, but THEME_preprocess_node() seems to work. kind of. if i do
$variables['title'] = 'hello world';
it works, but it still won't let me put the span tags in. I have found the reason for that, titles aren't allowed to have code because of XSS threats.
OK. Fine. Fair enough.
There is options in the code to allow you to to allow certain tags (i found documentation, then i lost it ... argghh)
I will keep this question updated as I go