I have read similar questions on here, but I'm still struggling for an answer for this.
I'm trying to implement hook_bootstrap_colorize_text() to alter button colors in a Bootstrap sub-theme.
I would like to add some specific text items to the array that dictates how the buttons are colorizes. For example, I have some buttons that have the "btn-default" class, and I would like to indicate specific texts to which should have “btn-success" or "btn-warning" instead.
The bootstrap.api.php describes this process:
/**
* Allows sub-themes to alter the array used for colorizing text.
* …
* @see _bootstrap_colorize_text()
*/
function hook_bootstrap_colorize_text_alter(array &$texts) {
// This matches the exact string: "My Unique Button Text".
$texts['matches'][t('My Unique Button Text')] = 'primary';
// This would also match the string above, however the class returned would
// also be the one above; "matches" takes precedence over "contains".
$texts['contains'][t('Unique')] = 'notice';
// Remove matching for strings that contain "apply":
unset($texts['contains'][t('Apply')]);
// Change the class that matches "Rebuild" (originally "warning"):
$texts['contains'][t('Rebuild')] = 'success';
}
Therefore, I have attempted to implement the following code in my sub-theme (methodsTheme) template.php file without success.
<?php
// Implements hook_bootstrap_colorize_text_alter() to alter button colors.
function methodstheme_bootstrap_colorize_text_alter(array &$texts) {
$texts['matches'][t('Request Rotation')] = 'success';
$texts['contains'][t('Notify')] = 'success';
$texts['contains'][t('Set')] = 'success';
$texts['contains'][t('Mark')] = 'success';
$texts['contains'][t('Assign')] = 'success';
$texts['contains'][t('Report')] = 'warning';
$texts['contains'][t('Request')] = 'info';
}
?>
I've also tried:
<?php
// Implements hook_bootstrap_colorize_text_alter() to alter button colors.
function methodstheme_bootstrap_colorize_text_alter(&$texts) {
$texts['matches'][t('Request Rotation')] = 'success';
$texts['contains'][t('Notify')] = 'success';
$texts['contains'][t('Set')] = 'success';
$texts['contains'][t('Mark')] = 'success';
$texts['contains'][t('Assign')] = 'success';
$texts['contains'][t('Report')] = 'warning';
$texts['contains'][t('Request')] = 'info';
}
?>
And, I've also tried:
<?php
// Implements hook_bootstrap_colorize_text_alter() to alter button colors.
function methodstheme_bootstrap_colorize_text_alter(&$texts) {
$texts = array(
'matches' => array(
t('Request Rotation') => 'success',
),
'contains' => array(
t('Notify') => 'success',
t('Set') => 'success',
t('Mark') => 'success',
t('Assign') => 'success',
t('Report') => 'warning',
t('Request') => 'info',
),
);
}
?>
And, yes, after each attempt, I'm clearing the caches to see if the changes to the code are implemented to the desired result. However, I'm still emptyhanded. I'm placing the template.php file in my sites/all/themes/methodstheme/templates folder. The sub-theme was already established and working well (i.e., it is set-up properly, I believe).
I'm using Drupal 7.64 (with install profile varbase, but I've mostly removed all usage of the varbase profile and modules) and latest version of Bootstrap 3 theme as the base theme.
Can anyone offer some help or suggestions on what the issue may be?