Skip to content

Commit

Permalink
Fixes #3676 Course Display Changes (#3677)
Browse files Browse the repository at this point in the history
  • Loading branch information
tadean authored Sep 25, 2024
1 parent a75f794 commit 7b76b7c
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 22 deletions.
12 changes: 12 additions & 0 deletions modules/custom/az_course/az_course.module
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ function az_course_help($route_name, RouteMatchInterface $route_match) {
}
}

/**
* Implements hook_theme().
*/
function az_course_theme() {
return [
'field__node__field_az_course_instructor__az_course' => [
'template' => 'field--node--field-az-course-instructor--az-course',
'base hook' => 'field',
],
];
}

/**
* Implements hook_migration_plugins_alter().
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ third_party_settings:
weight: 0
format_type: html_element
format_settings:
classes: 'card mb-4'
classes: 'card card-clickable border hover mb-4'
show_empty_fields: false
id: ''
element: div
Expand All @@ -44,18 +44,32 @@ third_party_settings:
group_card_block:
children:
- smart_title
- field_az_course_description
- field_az_course_units
- links
label: 'Card Body'
- group_text_muted
label: 'Card Link'
parent_name: group_card
region: content
weight: 2
format_type: html_element
format_type: link
format_settings:
classes: card-body
classes: 'card-body'
show_empty_fields: true
id: ''
target: entity
custom_uri: ''
target_attribute: default
group_text_muted:
children:
- field_az_course_description
- field_az_course_units
label: 'Text Muted'
parent_name: group_card_block
region: content
weight: 4
format_type: html_element
format_settings:
classes: 'text-muted font-weight-normal'
show_empty_fields: false
id: ''
element: div
show_label: false
label_element: h3
Expand All @@ -70,7 +84,9 @@ third_party_settings:
smart_title__tag: h5
smart_title__classes:
- card-title
- mt-0
- text-midnight
- mt-1
- hover-text-underline
id: node.az_course.az_card
targetEntityType: node
bundle: az_course
Expand All @@ -81,7 +97,7 @@ content:
label: hidden
settings: { }
third_party_settings: { }
weight: 4
weight: 5
region: content
field_az_course_units:
type: number_integer
Expand All @@ -90,11 +106,6 @@ content:
thousand_separator: ''
prefix_suffix: true
third_party_settings: { }
weight: 5
region: content
links:
settings: { }
third_party_settings: { }
weight: 6
region: content
smart_title:
Expand All @@ -112,3 +123,4 @@ hidden:
field_az_course_types: true
field_az_subject_and_catalog: true
field_az_subject_code: true
links: true
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,112 @@ dependencies:
- field.field.node.az_course.field_az_subject_code
- node.type.az_course
module:
- field_group
- linkit
- smart_title
- text
- user
third_party_settings:
smart_title:
enabled: false
field_group:
group_instructor:
children:
- field_az_course_instructor
label: Instructor(s)
parent_name: group_card
region: content
weight: 5
format_type: html_element
format_settings:
classes: ''
show_empty_fields: false
id: ''
element: div
show_label: true
label_element: h2
label_element_classes: 'font-weight-bold mb-0 text-body text-size-h6'
attributes: ''
effect: none
speed: fast
group_row:
children:
- group_details
- group_description
label: Row
parent_name: ''
region: content
weight: 0
format_type: html_element
format_settings:
classes: 'row mb-4'
show_empty_fields: false
id: ''
element: div
show_label: false
label_element: h3
label_element_classes: ''
attributes: ''
effect: none
speed: fast
group_description:
children:
- field_az_course_description
label: Description
parent_name: group_row
region: hidden
weight: 1
format_type: html_element
format_settings:
classes: 'col-12 col-md-8'
show_empty_fields: false
id: ''
element: div
show_label: false
label_element: h3
label_element_classes: ''
attributes: ''
effect: none
speed: fast
group_details:
children:
- group_card
label: Details
parent_name: group_row
region: content
weight: 5
format_type: html_element
format_settings:
classes: 'col-12 col-md-4'
show_empty_fields: false
id: ''
element: div
show_label: false
label_element: h3
label_element_classes: ''
attributes: ''
effect: none
speed: fast
group_card:
children:
- field_az_course_units
- group_instructor
label: Card
parent_name: group_details
region: content
weight: 3
format_type: html_element
format_settings:
classes: 'card card-body'
show_empty_fields: false
id: ''
element: div
show_label: false
label_element: h3
label_element_classes: ''
attributes: ''
effect: none
speed: fast
id: node.az_course.default
targetEntityType: node
bundle: az_course
Expand All @@ -31,7 +131,20 @@ content:
label: hidden
settings: { }
third_party_settings: { }
weight: 1
weight: 2
region: content
field_az_course_instructor:
type: linkit
label: hidden
settings:
trim_length: 80
url_only: false
url_plain: false
rel: '0'
target: '0'
linkit_profile: default
third_party_settings: { }
weight: 3
region: content
field_az_course_units:
type: number_integer
Expand All @@ -40,21 +153,16 @@ content:
thousand_separator: ''
prefix_suffix: true
third_party_settings: { }
weight: 2
region: content
links:
settings: { }
third_party_settings: { }
weight: 0
weight: 4
region: content
hidden:
field_az_academic_program: true
field_az_catalog_number: true
field_az_course_attributes: true
field_az_course_instructor: true
field_az_course_term: true
field_az_course_title: true
field_az_course_types: true
field_az_subject_and_catalog: true
field_az_subject_code: true
links: true
smart_title: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{#
/**
* @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 classes = [
'field',
'field--name-' ~ field_name|clean_class,
'field--type-' ~ field_type|clean_class,
'field--label-' ~ label_display,
]
%}
{%
set title_classes = [
'field__label',
label_display == 'visually_hidden' ? 'visually-hidden',
label_display == 'above' ? 'h3',
label_display == 'inline' ? 'font-weight-bolder',
label_display == 'inline' ? 'trailing-colon',
]
%}

{% if label_hidden %}
{% if multiple %}
<ul{{ attributes.addClass(classes, 'field__items') }}>
{% for item in items %}
<li{{ item.attributes.addClass('field__item') }}>{{ item.content }}</li>
{% endfor %}
</ul>
{% else %}
{% for item in items %}
<div{{ attributes.addClass(classes, 'field__item') }}>{{ item.content }}</div>
{% endfor %}
{% endif %}
{% else %}
<div{{ attributes.addClass(classes) }}>
<div{{ title_attributes.addClass(title_classes) }}>{{ label }}</div>
{% if multiple %}
<ul class='field__items'>
{% endif %}
{% for item in items %}
<li{{ item.attributes.addClass('field__item') }}>{{ item.content }}</li>
{% endfor %}
{% if multiple %}
</ul>
{% endif %}
</div>
{% endif %}

0 comments on commit 7b76b7c

Please sign in to comment.