diff --git a/templates/paragraphs/paragraph--uw-para-options-block.html.twig b/templates/paragraphs/paragraph--uw-para-options-block.html.twig index 23a2a339df9be96b26346d8475d3e5336b2e5553..472a5d12bc15365dd06c8a3854eb6ee793a7905e 100644 --- a/templates/paragraphs/paragraph--uw-para-options-block.html.twig +++ b/templates/paragraphs/paragraph--uw-para-options-block.html.twig @@ -1,21 +1,12 @@ - -{% set options = [] %} -{% for item in content.field_uw_options|field_value %} - {% set options = options|merge - ([{ link_description: item['#paragraph'].field_uw_link_description.value, - link_uri: item['#paragraph'].field_uw_option_link.value[0]['uri'], - link_title: item['#paragraph'].field_uw_option_link.value[0]['title'], - link_colouring: item['#paragraph'].field_uw_option_colouring.value, - }]) - %} -{% endfor %} - {% include '@organisms/single-page/options-block/options-block.twig' with { 'display_title': display_title, 'title': content.field_uw_block_title|field_value, - 'options': options, + 'link_description': link_description, + 'link_uri': link_uri, + 'link_title': link_title, + 'link_colouring': link_colouring, 'sources': sources, 'output_image_tag': output_image_tag, 'img_element': img_element['#uri'], 'alt': alt -}%} +}%} \ No newline at end of file diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index 485385d2dbfe389191b60eaeb2821ec13fc03ac7..af280405edf24e8381d5e2befbcc9ea1a0fc0b1c 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -124,6 +124,7 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) { //Get value from field_uw_options field; $field_values = $variables['paragraph']->get('field_uw_options')->getValue(); + $i = 0; foreach ($field_values as $field_value) { @@ -144,13 +145,38 @@ function uw_fdsu_theme_resp_preprocess_paragraph(&$variables) { // Set uri and image style id. $variables['uri'] = $file->getFileUri(); $variables['responsive_image_style_id'] = 'uw_resp_is_sph_header_image'; - // Call template function from responsive image core module. // It sets variables for srcset, media, type and img_element // for the responsive image style. template_preprocess_responsive_image($variables); + + // Add all variables to an array. + $options2[$i]['alt'] = $variables['alt']; + $options2[$i]['uri'] = $variables['uri']; + $options2[$i]['responsive_image_style_id'] = $variables['responsive_image_style_id']; + $options2[$i]['sources'] = $variables['sources']; + $options2[$i]['output_image_tag'] = $variables['output_image_tag']; + $options2[$i]['img_element'] = $variables['img_element']; } + + // Get colouring value and add to the variable array. + $link_colouring = $p->field_uw_option_colouring->first()->getValue(); + $options2[$i]['link_colouring'] = $link_colouring['value']; + + // Get link description and add to the variable array. + $link_description = $p->field_uw_link_description->first()->getValue(); + $options2[$i]['link_description'] = $link_description['value']; + + // Get link uri and title and add to the variable array. + $link = $p->field_uw_option_link->first()->getValue(); + $options2[$i]['link_uri'] = $link['uri']; + $options2[$i]['link_title'] = $link['title']; + + $i++; } + + $variables['options2'] = $options2; + vardumper($options2); break; } }