drupal 8 theme suggestions code example
Example 1: drupal 8 form element theme suggestions
function MYMODULE_theme_suggestions_form_element_alter(array &$suggestions, array $variables, $hook) {
if ( $variables['element']['#id'] === 'FORMID') {
$suggestions[] = $hook . '__custom';
}
}
Example 2: drupal 8 suggestions
function MYMODULE_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
if (\Drupal::currentUser()
->isAuthenticated() && in_array($hook, array(
'node',
'taxonomy_term',
))) {
$suggestions[] = $hook . '__' . 'logged_in';
}
}