diff --git a/crossword.module b/crossword.module index 5bc35c4..aee129f 100644 --- a/crossword.module +++ b/crossword.module @@ -101,6 +101,11 @@ function crossword_theme($existing, $type, $theme, $path) { 'crossword_instructions' => [ 'variables' => [], ], + 'crossword_active_clues' => [ + 'variables' => [ + 'pseudofield' => FALSE, + ], + ], ]; } @@ -192,3 +197,12 @@ function crossword_theme_suggestions_crossword_grid_row_alter(array &$suggestion $suggestions[] = 'crossword_grid_row__pseudofield'; } } + +/** + * Implements hook_theme_suggestions_HOOK_alter() for crossword active clues. + */ +function crossword_theme_suggestions_crossword_active_clues_alter(array &$suggestions, array $variables) { + if ($variables['pseudofield']) { + $suggestions[] = 'crossword_active_clues__pseudofield'; + } +} diff --git a/modules/crossword_pseudofields/src/Plugin/Field/FieldFormatter/CrosswordPseudofieldsFormatter.php b/modules/crossword_pseudofields/src/Plugin/Field/FieldFormatter/CrosswordPseudofieldsFormatter.php index 44265b7..f56cd5e 100644 --- a/modules/crossword_pseudofields/src/Plugin/Field/FieldFormatter/CrosswordPseudofieldsFormatter.php +++ b/modules/crossword_pseudofields/src/Plugin/Field/FieldFormatter/CrosswordPseudofieldsFormatter.php @@ -67,7 +67,8 @@ class CrosswordPseudofieldsFormatter extends CrosswordFormatter { 'notepad' => $this->getNotepad($data), 'controls' => $this->getControls($file), 'active_clue' => [ - '#markup' => '
', + '#theme' => 'crossword_active_clues', + '#pseudofield' => TRUE, ], 'grid' => $this->getGrid($data), 'across' => $this->getAcross($data), diff --git a/src/Plugin/Field/FieldFormatter/CrosswordFormatter.php b/src/Plugin/Field/FieldFormatter/CrosswordFormatter.php index e900dc4..1de3aad 100644 --- a/src/Plugin/Field/FieldFormatter/CrosswordFormatter.php +++ b/src/Plugin/Field/FieldFormatter/CrosswordFormatter.php @@ -310,6 +310,10 @@ class CrosswordFormatter extends FileFormatterBase { 'down' => $this->getDown($data), 'grid' => $this->getGrid($data), 'controls' => $this->getControls($file), + 'active_clue' => [ + '#theme' => 'crossword_active_clues', + '#pseudofield' => $this->getPluginId() == 'crossword_pseudofields', + ], ], '#attached' => [ 'library' => [ diff --git a/templates/crossword-active-clues.html.twig b/templates/crossword-active-clues.html.twig new file mode 100644 index 0000000..01fef98 --- /dev/null +++ b/templates/crossword-active-clues.html.twig @@ -0,0 +1,4 @@ +