Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OEL-2633: Show gallery field in project detail page. #241

Merged
merged 5 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies:
- entity_reference_revisions
- field_group
- link
- oe_whitelabel_helper
- rdf_skos
- text
- user
Expand Down Expand Up @@ -123,6 +124,13 @@ content:
third_party_settings: { }
weight: 8
region: content
oe_cx_gallery:
type: oe_whitelabel_helper_gallery
label: hidden
settings: { }
third_party_settings: { }
weight: 9
region: content
oe_cx_impacts:
type: text_default
label: hidden
Expand Down Expand Up @@ -216,7 +224,6 @@ hidden:
oe_content_legacy_link: true
oe_content_navigation_title: true
oe_content_short_title: true
oe_cx_gallery: true
oe_departments: true
oe_documents: true
oe_featured_media: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
langcode: en
status: true
dependencies:
config:
- core.entity_view_mode.node.full
- field.field.node.oe_project.body
- field.field.node.oe_project.oe_cx_achievements_and_milestone
- field.field.node.oe_project.oe_cx_gallery
- field.field.node.oe_project.oe_cx_impacts
- field.field.node.oe_project.oe_cx_lead_contributors
- field.field.node.oe_project.oe_cx_objective
- field.field.node.oe_project.oe_departments
- field.field.node.oe_project.oe_documents
- field.field.node.oe_project.oe_featured_media
- field.field.node.oe_project.oe_project_budget
- field.field.node.oe_project.oe_project_budget_eu
- field.field.node.oe_project.oe_project_calls
- field.field.node.oe_project.oe_project_contact
- field.field.node.oe_project.oe_project_coordinators
- field.field.node.oe_project.oe_project_dates
- field.field.node.oe_project.oe_project_eu_budget
- field.field.node.oe_project.oe_project_eu_contrib
- field.field.node.oe_project.oe_project_funding_programme
- field.field.node.oe_project.oe_project_locations
- field.field.node.oe_project.oe_project_participants
- field.field.node.oe_project.oe_project_result_files
- field.field.node.oe_project.oe_project_results
- field.field.node.oe_project.oe_project_website
- field.field.node.oe_project.oe_reference_code
- field.field.node.oe_project.oe_subject
- field.field.node.oe_project.oe_summary
- field.field.node.oe_project.oe_teaser
- node.type.oe_project
module:
- datetime_range
- entity_reference_revisions
- field_group
- link
- oe_whitelabel_helper
- rdf_skos
- text
- user
third_party_settings:
field_group:
group_project_details:
children:
- group_website
- group_coordinators
label: 'Project details'
parent_name: ''
region: content
weight: 2
format_type: html_element
format_settings:
classes: ''
show_empty_fields: false
id: ''
element: div
show_label: false
label_element: h3
label_element_classes: 'fw-bold mb-4'
attributes: ''
effect: none
speed: fast
group_coordinators:
children:
- oe_project_coordinators
label: Coordinators
parent_name: group_project_details
region: content
weight: 11
format_type: oe_whitelabel_helper_description_list_pattern
format_settings: { }
group_budget:
children:
- extra_field_oe_whitelabel_extra_project_project_budget
- extra_field_oe_whitelabel_extra_project_eu_contrib
label: Budget
parent_name: ''
region: content
weight: 1
format_type: html_element
format_settings:
classes: ''
show_empty_fields: false
id: ''
element: div
show_label: false
label_element: h3
label_element_classes: ''
attributes: ''
effect: none
speed: fast
group_website:
children:
- oe_project_website
- oe_project_funding_programme
- oe_reference_code
label: Website
parent_name: group_project_details
region: content
weight: 10
format_type: oe_whitelabel_helper_description_list_pattern
format_settings: { }
id: node.oe_project.full
targetEntityType: node
bundle: oe_project
mode: full
content:
extra_field_oe_whitelabel_extra_project_eu_contrib:
settings: { }
third_party_settings: { }
weight: 6
region: content
extra_field_oe_whitelabel_extra_project_project_budget:
settings: { }
third_party_settings: { }
weight: 5
region: content
oe_cx_achievements_and_milestone:
type: text_default
label: hidden
settings: { }
third_party_settings: { }
weight: 8
region: content
oe_cx_gallery:
type: oe_whitelabel_helper_gallery
label: hidden
settings: { }
third_party_settings: { }
weight: 9
region: content
oe_cx_impacts:
type: text_default
label: hidden
settings: { }
third_party_settings: { }
weight: 5
region: content
oe_cx_lead_contributors:
type: entity_reference_revisions_entity_view
label: hidden
settings:
view_mode: default
link: ''
third_party_settings: { }
weight: 6
region: content
oe_cx_objective:
type: text_default
label: hidden
settings: { }
third_party_settings: { }
weight: 4
region: content
oe_project_coordinators:
type: entity_reference_revisions_label
label: hidden
settings:
link: false
third_party_settings: { }
weight: 4
region: content
oe_project_dates:
type: daterange_default
label: hidden
settings:
timezone_override: ''
format_type: oe_whitelabel_project_date
separator: '-'
third_party_settings: { }
weight: 0
region: content
oe_project_funding_programme:
type: skos_concept_entity_reference_label
label: hidden
settings:
link: false
third_party_settings: { }
weight: 4
region: content
oe_project_participants:
type: entity_reference_revisions_entity_view
label: hidden
settings:
view_mode: default
link: ''
third_party_settings: { }
weight: 7
region: content
oe_project_website:
type: link
label: hidden
settings:
trim_length: 80
url_only: false
url_plain: false
rel: ''
target: ''
third_party_settings: { }
weight: 3
region: content
oe_reference_code:
type: string
label: hidden
settings:
link_to_entity: false
third_party_settings: { }
weight: 6
region: content
oe_summary:
type: text_default
label: hidden
settings: { }
third_party_settings: { }
weight: 3
region: content
hidden:
body: true
langcode: true
links: true
oe_content_content_owner: true
oe_content_legacy_link: true
oe_content_navigation_title: true
oe_content_short_title: true
oe_departments: true
oe_documents: true
oe_featured_media: true
oe_project_budget: true
oe_project_budget_eu: true
oe_project_calls: true
oe_project_contact: true
oe_project_eu_budget: true
oe_project_eu_contrib: true
oe_project_locations: true
oe_project_result_files: true
oe_project_results: true
oe_subject: true
oe_teaser: true
search_api_excerpt: true
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function _oe_whitelabel_extra_project_preprocess_inpage_nav(array &$variables):
'oe_cx_lead_contributors',
'oe_project_participants',
'oe_cx_achievements_and_milestone',
'oe_cx_gallery',
];
foreach ($variables['content'] as &$item) {
if (!array_key_exists('#field_name', $item)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@ function oe_whitelabel_extra_project_post_update_00002(): string {

return 'Action bar field group was added to the project content banner view display.';
}

/**
* Show the gallery field in project full view mode.
*/
function oe_whitelabel_extra_project_post_update_00003(): void {
ConfigImporter::importSingle('module', 'oe_whitelabel_extra_project', '/config/post_updates/00003_gallery_field', 'core.entity_view_display.node.oe_project.full');
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ public function testRendering(): void {
$paragraph->save();

$file_url_generator = \Drupal::service('file_url_generator');
$core_10_1_0 = version_compare(\Drupal::VERSION, '10.1.0', '>=');
$fn_get_filepath = static fn($entity, $field) => $file_url_generator->generate($entity->get($field)->entity->getFileUri())->toString();
$expected_items = [
[
'thumbnail' => [
'caption_title' => 'Image title',
'rendered' => sprintf(
'<img loading="lazy" src="%s" width="200" height="89" alt="Alt text" class="img-fluid">',
$file_url_generator->generate($image->get('oe_media_image')->entity->getFileUri())->toString(),
$fn_get_filepath($image, 'oe_media_image')
),
],
'media' => [
'caption_title' => 'Image title',
'rendered' => sprintf(
'<img loading="lazy" data-src="%s" width="200" height="89" alt="Alt text" class="img-fluid">',
$file_url_generator->generate($image->get('oe_media_image')->entity->getFileUri())->toString(),
$fn_get_filepath($image, 'oe_media_image')
),
],
],
Expand All @@ -81,7 +81,7 @@ public function testRendering(): void {
'caption_title' => 'Euro with miniature figurines',
'rendered' => sprintf(
'<img loading="lazy" src="%s" width="639" height="426" alt="Euro with miniature figurines" class="img-fluid">',
$file_url_generator->generate($avportal_photo->get('thumbnail')->entity->getFileUri())->toString(),
$fn_get_filepath($avportal_photo, 'thumbnail')
),
],
'media' => [
Expand All @@ -94,7 +94,7 @@ public function testRendering(): void {
'caption_title' => 'Economic and Financial Affairs Council - Arrivals',
'rendered' => sprintf(
'<img loading="lazy" src="%s" width="352" height="200" alt="" class="img-fluid">',
$file_url_generator->generate($avportal_video->get('thumbnail')->entity->getFileUri())->toString(),
$fn_get_filepath($avportal_video, 'thumbnail')
),
'play_icon' => TRUE,
],
Expand All @@ -108,17 +108,16 @@ public function testRendering(): void {
'caption_title' => 'Energy, let\'s save it!',
'rendered' => sprintf(
'<img loading="lazy" src="%s" width="480" height="360" alt="" class="img-fluid">',
$file_url_generator->generate($video->get('thumbnail')->entity->getFileUri())->toString(),
$fn_get_filepath($video, 'thumbnail')
),
'play_icon' => TRUE,
],
'media' => [
'caption_title' => 'Energy, let\'s save it!',
'rendered' => sprintf(
'<iframe data-src="%s?url=https%%3A//www.youtube.com/watch%%3Fv%%3D1-g73ty9v04&amp;max_width=0&amp;max_height=0&amp;hash=%s" frameborder="0" allowtransparency width="459" height="344" class="media-oembed-content"%s title="Energy, let\'s save it!"></iframe>',
Url::fromRoute('media.oembed_iframe')->setAbsolute($core_10_1_0)->toString(),
\Drupal::service('media.oembed.iframe_url_helper')->getHash('https://www.youtube.com/watch?v=1-g73ty9v04', 0, 0),
$core_10_1_0 ? ' loading="eager"' : ''
'<iframe data-src="%s?url=https%%3A//www.youtube.com/watch%%3Fv%%3D1-g73ty9v04&amp;max_width=0&amp;max_height=0&amp;hash=%s" frameborder="0" allowtransparency width="459" height="344" class="media-oembed-content" loading="eager" title="Energy, let\'s save it!"></iframe>',
Url::fromRoute('media.oembed_iframe')->setAbsolute()->toString(),
\Drupal::service('media.oembed.iframe_url_helper')->getHash('https://www.youtube.com/watch?v=1-g73ty9v04', 0, 0)
),
],
],
Expand Down
1 change: 1 addition & 0 deletions templates/content/node--oe-project--full.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
{{ _self.field_with_header(content.oe_cx_lead_contributors) }}
{{ _self.field_with_header(content.oe_project_participants) }}
{{ _self.field_with_header(content.oe_cx_achievements_and_milestone) }}
{{ _self.field_with_header(content.oe_cx_gallery) }}
{% endblock %}
{% endset %}

Expand Down
Loading