From 811dc88268ad669f221dbb379d20d43d6fce66d1 Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Tue, 30 Oct 2018 07:58:22 -0300 Subject: [PATCH] WIP --- bibcite_footnotes.module | 15 ++++++++++++++- templates/footnote-link.html.twig | 16 ++++++++++++++++ templates/footnote-list.html.twig | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 templates/footnote-link.html.twig diff --git a/bibcite_footnotes.module b/bibcite_footnotes.module index 8aed8a1..3d6aa9b 100644 --- a/bibcite_footnotes.module +++ b/bibcite_footnotes.module @@ -135,6 +135,16 @@ function _bibcite_footnotes_reference_array_cmp($a, $b) { return strcmp($a1, $b1); } +function bibcite_footnotes_preprocess_footnote_link(&$variables) { +// $variables['fn']['fn']['#type'] = 'markeup'; +// $variables['fn']['fn']['#markup'] = '

Hello!

'; + $fn = $variables['fn']['fn']; + $url = Url::fromUserInput('#' . $fn['ref_id'], ['attributes' => ['id' => $fn['fn_id'], 'class' => 'footnote-link']]); + $link = Link::fromTextAndUrl(($dont_show_backlink_text && $reference_entity_id ? '^' : $fn['value']), $url)->toRenderable(); + $build[] = $link; + +} + /** * Implements hook_theme(). */ @@ -148,11 +158,14 @@ function bibcite_footnotes_theme() { function bibcite_footnotes_theme_registry_alter(&$theme_registry) { unset($theme_registry['footnote_list']['function']); -// $theme_registry['footnote_list']['function'] = 'bibcite_footnotes_theme_footnote_list'; $theme_registry['footnote_list']['path'] = drupal_get_path('module', 'bibcite_footnotes') . '/templates'; $theme_registry['footnote_list']['template'] = 'footnote-list'; $theme_registry['footnote_list']['variables']['notes'] = []; $theme_registry['footnote_list']['variables']['references'] = []; $theme_registry['footnote_list']['variables']['footnotes'] = []; + + unset($theme_registry['footnote_link']['function']); + $theme_registry['footnote_link']['path'] = drupal_get_path('module', 'bibcite_footnotes') . '/templates'; + $theme_registry['footnote_link']['template'] = 'footnote-link'; } diff --git a/templates/footnote-link.html.twig b/templates/footnote-link.html.twig new file mode 100644 index 0000000..0328921 --- /dev/null +++ b/templates/footnote-link.html.twig @@ -0,0 +1,16 @@ +{# +/** + * @file footnote-link.html.twig + * Default theme implementation to present an inline reference footnote link. + * + * Available variables: + * - fn: Components of the footnote + * - link: Rendered link. + * - attributes: HTML attributes for the container element. + * + * @see template_preprocess_footnote_link(). + * + * @ingroup themeable + */ +#} +{{ fn }} \ No newline at end of file diff --git a/templates/footnote-list.html.twig b/templates/footnote-list.html.twig index 288c64e..71644df 100644 --- a/templates/footnote-list.html.twig +++ b/templates/footnote-list.html.twig @@ -17,5 +17,5 @@ {{ notes }} - {{ references }} + {{ references }}