diff --git a/templates/paragraphs/paragraph--uw-para-quicklinks-block.html.twig b/templates/paragraphs/paragraph--uw-para-quicklinks-block.html.twig index 26961a135f24c1683ac9354b45e54571ed10dd7e..a73a5f041b539364df702300d110f84a5b6ae557 100644 --- a/templates/paragraphs/paragraph--uw-para-quicklinks-block.html.twig +++ b/templates/paragraphs/paragraph--uw-para-quicklinks-block.html.twig @@ -2,5 +2,5 @@ 'anchor_link': anchor_link, 'display_title': display_title, 'title': content.field_uw_block_title|field_value, - 'quicklinks': content.field_uw_quicklink + 'quicklinks': quicklinks } %} \ No newline at end of file diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index d3a9f9294bcb755eeb99a49e74652965a547b3c0..cab84970e0508889b21f4ea200bdb705f74f38b1 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -126,21 +126,46 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) { // Set the anchor link. $variables['anchor_link'] = _uw_fdsu_theme_resp_get_field_value_from_paragraph($variables['paragraph'], 'field_uw_anchor_link'); - // Set the responsive image variables. - // _uw_fdsu_theme_resp_add_responsive_image_variables($variables, 'field_uw_icon_image', 'uw_resp_is_marketing_item'); + $field_values = $variables['paragraph']->get('field_uw_quicklink')->getValue(); + + unset($quicklinks); + $counter = 0; + + // Process field_uw_options field which includes multiple entities. + foreach ($field_values as $field_value) { + + // Get paragraph entity of field_uw_options field from the target_id. + $paragraph = \Drupal\paragraphs\Entity\Paragraph::load($field_value['target_id']); + + // Get the field entity from the paragraph. + $field = $paragraph->field_uw_icon_image->first(); - // Set link section title - //$variables['quicklinks'] = _uw_fdsu_theme_resp_get_field_value_from_paragraph($variables['paragraph'], array( - // [0] => [ - // 'img_src' => 'field_uw_icon_image', - // 'link_section_title' => 'field_uw_link_section_title', - // 'links' => 'field_uw_quicklinks_links', - //]); -//vardumper($variables['content']['field_uw_quicklink']); + // If there is a field to process, process it. + if (isset($field)) { + // Get the sources for the responsive image. + $quicklinks[$counter]['sources'] = _uw_fdsu_theme_resp_add_responsive_image_variables($variables, $field, 'uw_resp_is_marketing_item'); + } -$sources= _uw_fdsu_theme_resp_add_responsive_image_variables($variables['content']['field_uw_quicklink'][0], 'field_uw_icon_image', 'uw_resp_is_marketing_item', TRUE); -vardumper($sources); + // Set the link section title. + $quicklinks[$counter]['link_section_title'] = $paragraph->get('field_uw_link_section_title')->getValue()[0]['value']; + + // Get the links out of the quicklink paragraph. + $links = $paragraph->get('field_uw_quicklinks_links')->getValue(); + + // Step through each link and set the url and content. + foreach ($links as $link) { + $quicklinks[$counter]['links'][] = array( + 'link_url' => $link['uri'], + 'link_content' => $link['title'] + ); + } + + // Increment the counter used for the quicklinks array. + $counter++; + } + // Set the quicklinks variable to be used in the template. + $variables['quicklinks'] = $quicklinks; break; }