diff --git a/bibcite_footnotes.module b/bibcite_footnotes.module index 754f094..4b9d702 100644 --- a/bibcite_footnotes.module +++ b/bibcite_footnotes.module @@ -27,6 +27,7 @@ function bibcite_footnotes_theme() { 'variables' => [ 'notes' => [], 'note_type' => [], + 'config' => [], ], ], ]; @@ -70,7 +71,7 @@ function bibcite_footnotes_preprocess_footnote_list(&$variables) { '#wrapper_attributes' => ['class' => 'container'], ]; - $references['#attached']['library'][] = 'bibcite_footnotes/reference_footnote'; + $notes['#attached']['library'][] = 'bibcite_footnotes/reference_footnote'; $dont_show_backlink_text = $config->get('filters.filter_reference_footnotes.settings.reference_dont_show_backlink_text'); $sort_references_by = $config->get('filters.filter_reference_footnotes.settings.reference_sort_by'); $citation_tools = new CitationTools(); diff --git a/src/Plugin/Filter/ReferenceFootnotesFilter.php b/src/Plugin/Filter/ReferenceFootnotesFilter.php index faeacda..0315182 100644 --- a/src/Plugin/Filter/ReferenceFootnotesFilter.php +++ b/src/Plugin/Filter/ReferenceFootnotesFilter.php @@ -147,15 +147,17 @@ class ReferenceFootnotesFilter extends FootnotesFilter { if (count($store_matches) > 0) { // Separate out endontes and reference notes. - $notes = $this->extractNotesByType(self::NOTES, $store_matches); - $references = $this->extractNotesByType(self::REFERENCES, $store_matches); + $notes = $this->extractNotesByType(self::ENDNOTE, $store_matches); + $references = $this->extractNotesByType(self::REFERENCE, $store_matches); // Only if there are stored fn matches, pass the array of fns to be // themed as a list $markup = [ - '#theme' => 'footnote_list', - '#footnotes' => $store_matches, + '#theme' => 'bibcite_footnote_list', + '#footnotes' => $notes,, + '#note_type' => self::ENDNOTE, + '#config' => $this->settings, ]; $str = \Drupal::service('renderer')->render($markup, FALSE); } @@ -256,7 +258,7 @@ class ReferenceFootnotesFilter extends FootnotesFilter { // Drupal 7 requires we use "render element" which just introduces a wrapper // around the old array. $fn = [ - '#theme' => 'footnote_link', + '#theme' => 'bibcite_footnote_link', 'fn' => $fn, ]; @@ -338,8 +340,22 @@ class ReferenceFootnotesFilter extends FootnotesFilter { } protected function extractNotesByType($type, $footnotes) { + $notes = []; foreach ($footnotes as $fn) { - + switch ($type) { + case self::ENDNOTE: + if (!empty(fn['text'])) { + $notes[] = $fn; + } + break; + case self::REFERENCE: + if (!empty($fn['reference'])) { + $notes[] = $fn; + } + break; + } + ksm($fn); } + return $notes; } }