From 18daf5209de1e8f0db384810d1cad2f2db392ccd Mon Sep 17 00:00:00 2001 From: James Date: Wed, 7 Dec 2022 11:59:17 -0800 Subject: [PATCH] Add publication templates --- .../node--ubc-publication--full.html.twig | 192 ++++++++++++++++++ ...-field-publication-research-area.html.twig | 58 ++++++ .../field--field-publication-type.html.twig | 58 ++++++ 3 files changed, 308 insertions(+) create mode 100755 templates/content/node--ubc-publication--full.html.twig create mode 100644 templates/field/field--field-publication-research-area.html.twig create mode 100644 templates/field/field--field-publication-type.html.twig diff --git a/templates/content/node--ubc-publication--full.html.twig b/templates/content/node--ubc-publication--full.html.twig new file mode 100755 index 0000000..46db1cb --- /dev/null +++ b/templates/content/node--ubc-publication--full.html.twig @@ -0,0 +1,192 @@ +{# +/** + * @file + * Theme override to display a node. + * + * Available variables: + * - node: Full node entity. + * - id: The node ID. + * - bundle: The type of the node, for example, "page" or "article". + * - authorid: The user ID of the node author. + * - createdtime: Time the node was published formatted in Unix timestamp. + * - changedtime: Time the node was changed formatted in Unix timestamp. + * - label: The title of the node. + * - content: All node items. Use {{ content }} to print them all, + * or print a subset such as {{ content.field_example }}. Use + * {{ content|without('field_example') }} to temporarily suppress the printing + * of a given child element. + * - author_picture: The node author user entity, rendered using the "compact" + * view mode. + * - metadata: Metadata for this node. + * - date: Themed creation date field. + * - author_name: Themed author name field. + * - url: Direct URL of the current node. + * - display_submitted: Whether submission information should be displayed. + * - attributes: HTML attributes for the containing element. + * The attributes.class element may contain one or more of the following + * classes: + * - node: The current template type (also known as a "theming hook"). + * - node--type-[type]: The current node type. For example, if the node is an + * "Article" it would result in "node--type-article". Note that the machine + * name will often be in a short form of the human readable label. + * - node--view-mode-[view_mode]: The View Mode of the node; for example, a + * teaser would result in: "node--view-mode-teaser", and + * full: "node--view-mode-full". + * The following are controlled through the node publishing options. + * - node--promoted: Appears on nodes promoted to the front page. + * - node--sticky: Appears on nodes ordered above other non-sticky nodes in + * teaser listings. + * - node--unpublished: Appears on unpublished nodes visible only to site + * admins. + * - title_attributes: Same as attributes, except applied to the main title + * tag that appears in the template. + * - content_attributes: Same as attributes, except applied to the main + * content tag that appears in the template. + * - author_attributes: Same as attributes, except applied to the author of + * the node tag that appears in the template. + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * - view_mode: View mode; for example, "teaser" or "full". + * - teaser: Flag for the teaser state. Will be true if view_mode is 'teaser'. + * - page: Flag for the full page state. Will be true if view_mode is 'full'. + * - readmore: Flag for more state. Will be true if the teaser content of the + * node cannot hold the main body content. + * - logged_in: Flag for authenticated user status. Will be true when the + * current user is a logged-in member. + * - is_admin: Flag for admin user status. Will be true when the current user + * is an administrator. + * + * @see template_preprocess_node() + * + * @todo Remove the id attribute (or make it a class), because if that gets + * rendered twice on a page this is invalid CSS for example: two lists + * in different view modes. + */ +#} +{% set meta_attributes = create_attribute() %} +{% set link_attributes = create_attribute() %} + +{% + set classes = [ + 'node', + 'node--type-' ~ node.bundle|clean_class, + node.isPromoted() ? 'node--promoted', + node.isSticky() ? 'node--sticky', + not node.isPublished() ? 'node--unpublished', + view_mode ? 'node--view-mode-' ~ view_mode|clean_class, + ] +%} +{% + set meta_classes = [ + 'node__meta', + 'mt-2', + 'text-sm', + 'text-grey-700', + ] +%} +{% + set content_classes = [ + 'flow-root', + 'text-formatted', + 'node__content', + ] +%} +{% + set link_classes = [ + 'unit-button', + 'unit-button--simple', + ] +%} + +{% set date = node.createdtime|format_date('date_readable') %} +{% set firstname = node.Owner.field_user_first_name.value %} +{% set lastname = node.Owner.field_user_last_name.value %} +{% set author_name = [firstname, lastname]|join(' ') %} +{% if not (node.field_publication_link.isEmpty == true) and content.field_publication_link is defined %} + {% set exturl = content.field_publication_link[0]['#url']|raw %} + {% set exttitle = content.field_publication_link[0]['#title']|raw %} + {% set link_target = '_blank' %} +{% endif %} + + + {{ title_prefix }} + {% if not page %} + + {{ label }} + + {% endif %} + {{ title_suffix }} + {% if display_submitted %} + + {{ author_picture }} + + {% trans %}Posted on {{ date }}{% endtrans %} + + + {% endif %} + + {% if not node.isPublished() %} +
Unpublished
+ {% endif %} + {% if not (node.field_publication_image.isEmpty == true) and content.field_publication_image is defined %} +
{{ content.field_publication_image.0 }}
+ {% endif %} + {% if not (node.field_publication_lead.isEmpty == true) and content.field_publication_lead is defined %} +

Project Lead

+

{{ content.field_publication_lead.0 }}

+ {% endif %} + {% if not (node.field_publication_researchers.isEmpty == true) and content.field_publication_researchers is defined %} +

Researcher(s)

+

+ {%- for tag in node.field_publication_researchers -%}{{- tag.entity.title.value -}}{% if loop.last == false %}, {% endif %} + {%- endfor -%}

+ {% endif %} + {% if not (node.field_publication_journal.isEmpty == true) and content.field_publication_journal is defined %} +

Journal

+

{{ content.field_publication_journal.0 }}

+ {% endif %} + {% if not (node.field_publication_year.isEmpty == true) and content.field_publication_year is defined %} +

Date of Publication

+

{{ content.field_publication_year.0 }}

+ {% endif %} + {% if not (node.field_publication_description.isEmpty == true) and content.field_publication_description is defined %} +

Description

+
{{ content.field_publication_description.0 }}
+ {% endif %} + {% if not (node.body.isEmpty == true) and content.body is defined %} +

Details

+
{{ content.body.0 }}
+ {% endif %} + {% if not (node.field_publication_link.isEmpty == true) and content.field_publication_link is defined %} +

External Link

+

Read the Research Paper

+ {% endif %} + {% if not (node.field_publication_projects.isEmpty == true) and content.field_publication_projects is defined %} +

Related Projects

+

+ {%- for tag in node.field_publication_projects -%}{{- tag.entity.title.value -}}{% if loop.last == false %}, {% endif %} + {%- endfor -%}

+ {% endif %} + {{ content|without( + 'field_publication_projects', + 'field_publication_year', + 'field_publication_lead', + 'field_publication_description', + 'field_publication_researchers', + 'field_publication_link', + 'field_publication_image', + 'field_publication_type', + 'field_publication_journal', + 'field_publication_research_area', + 'body', + 'links') }} +
+ {% if (not (node.field_publication_type.isEmpty == true) and content.field_publication_type is defined) or (not (node.field_publication_research_area.isEmpty == true) and content.field_publication_research_area is defined) %} +
+ {{ content.field_publication_type }}{{ content.field_publication_research_area }} +
+ {% endif %} + + diff --git a/templates/field/field--field-publication-research-area.html.twig b/templates/field/field--field-publication-research-area.html.twig new file mode 100644 index 0000000..80ac8c4 --- /dev/null +++ b/templates/field/field--field-publication-research-area.html.twig @@ -0,0 +1,58 @@ +{# +/** + * @file + * Theme override for a field. + * + * To override output, copy the "field.html.twig" from the templates directory + * to your theme's directory and customize it, just like customizing other + * Drupal templates such as page.html.twig or node.html.twig. + * + * Instead of overriding the theming for all fields, you can also just override + * theming for a subset of fields using + * @link themeable Theme hook suggestions. @endlink For example, + * here are some theme hook suggestions that can be used for a field_foo field + * on an article node type: + * - field--node--field-foo--article.html.twig + * - field--node--field-foo.html.twig + * - field--node--article.html.twig + * - field--field-foo.html.twig + * - field--text-with-summary.html.twig + * - field.html.twig + * + * Available variables: + * - attributes: HTML attributes for the containing element. + * - label_hidden: Whether to show the field label or not. + * - title_attributes: HTML attributes for the title. + * - label: The label for the field. + * - multiple: TRUE if a field can contain multiple items. + * - items: List of all the field items. Each item contains: + * - attributes: List of HTML attributes for each item. + * - content: The field item's content. + * - entity_type: The entity type to which the field belongs. + * - field_name: The name of the field. + * - field_type: The type of the field. + * - label_display: The display settings for the label. + * + * + * @see template_preprocess_field() + */ +#} +{% + set title_classes = [ + label_display == 'visually_hidden' ? 'visually-hidden', + ] +%} + +{% if multiple %} + + {% for item in items %} + {{ item.content }} + {% endfor %} + +{% else %} + {% for item in items %} + + {{ item.content }} + + {% endfor %} +{% endif %} diff --git a/templates/field/field--field-publication-type.html.twig b/templates/field/field--field-publication-type.html.twig new file mode 100644 index 0000000..80ac8c4 --- /dev/null +++ b/templates/field/field--field-publication-type.html.twig @@ -0,0 +1,58 @@ +{# +/** + * @file + * Theme override for a field. + * + * To override output, copy the "field.html.twig" from the templates directory + * to your theme's directory and customize it, just like customizing other + * Drupal templates such as page.html.twig or node.html.twig. + * + * Instead of overriding the theming for all fields, you can also just override + * theming for a subset of fields using + * @link themeable Theme hook suggestions. @endlink For example, + * here are some theme hook suggestions that can be used for a field_foo field + * on an article node type: + * - field--node--field-foo--article.html.twig + * - field--node--field-foo.html.twig + * - field--node--article.html.twig + * - field--field-foo.html.twig + * - field--text-with-summary.html.twig + * - field.html.twig + * + * Available variables: + * - attributes: HTML attributes for the containing element. + * - label_hidden: Whether to show the field label or not. + * - title_attributes: HTML attributes for the title. + * - label: The label for the field. + * - multiple: TRUE if a field can contain multiple items. + * - items: List of all the field items. Each item contains: + * - attributes: List of HTML attributes for each item. + * - content: The field item's content. + * - entity_type: The entity type to which the field belongs. + * - field_name: The name of the field. + * - field_type: The type of the field. + * - label_display: The display settings for the label. + * + * + * @see template_preprocess_field() + */ +#} +{% + set title_classes = [ + label_display == 'visually_hidden' ? 'visually-hidden', + ] +%} + +{% if multiple %} + + {% for item in items %} + {{ item.content }} + {% endfor %} + +{% else %} + {% for item in items %} + + {{ item.content }} + + {% endfor %} +{% endif %}