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

Revert "Issue #1047 pulling block description to the label if it isn'… #295

Merged
merged 2 commits into from
Jul 26, 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 @@ -14,7 +14,4 @@
</div>
{% endset %}
{% endif %}
{% if element['#object'].info.value %}
{% set label = element['#object'].info.value %}
{% endif %}
{% include "@ts_wrin/fields/field--node--field-featured-experts.html.twig" %}
15 changes: 14 additions & 1 deletion themes/custom/ts_wrin/ts_wrin.theme
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ function ts_wrin_theme_suggestions_container_alter(array &$suggestions, array $v
}
}

/**
* Implements hook_preprocess_HOOK() for paragraph templates.
*/
function ts_wrin_preprocess_paragraph(array &$variables) {
// On person listing paragraphs, get the field title from the block title.
// Person listing blocks do this automatically.
if ($variables['paragraph']->getType() == 'person_listing') {
$variables["elements"]["field_block"][0]["field_featured_experts"]['#object']->overridden_label = $variables["elements"]["field_block"][0]["#block_content"]->info->value ?? NULL;
}
}

/**
* Implements hook_preprocess_page() for page.html.twig.
*/
Expand Down Expand Up @@ -161,9 +172,11 @@ function ts_wrin_preprocess_field(array &$variables) {
$variables["attributes"]["class"] = $variables["element"][0]["#attributes"]["class"];
$variables["attributes"]["class"][] = 'block';
}
// Add 'Show More Link' value to Featured Experts field.
// Add 'Show More Link' value to Featured Experts field and set the label to
// the block description for blocks embedded as paragraphs.
if ($variables['element']['#field_name'] == 'field_featured_experts') {
$object = $variables['element']['#object'];
$variables['label'] = $variables["element"]["#object"]->overridden_label ?? $variables['label'];
if (isset($object->field_show_more_link)) {
$variables["show_more_link"] = $object->field_show_more_link->value;
}
Expand Down