# Testimonial Slider With Modal using HubL & For Loop

**URL:** <https://community.hubspot.com/t/testimonial-slider-with-modal-using-hubl-for-loop/105064>\
**Category:** CMS Development\
**Tags:** css, html\
**Created:** [April 17, 2024, 5:57pm UTC](https://community.hubspot.com/t/testimonial-slider-with-modal-using-hubl-for-loop/105064 "2024-04-17T17:57:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cives](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cives/32/57633_2.png) [@cives](https://community.hubspot.com/u/cives)\
**Post date:** [April 17, 2024, 5:57pm UTC](https://community.hubspot.com/t/testimonial-slider-with-modal-using-hubl-for-loop/105064/1 "2024-04-17T17:57:43Z")

</div>

Hi there, hoping for a bit of help. I’m working on a custom module that features a testimonial slider that can read the full testimonial in a modal. The issue that I’m facing is the modal window needs to be outside and above the for loop.

My question is, using HubL/variables, etc — is there a way to store the testimonial quote and modal name from each loop iteration and use it in the code above.

```lia-code-sample
 <div class="page-center">
 <div id="test" class="modal-window">
 <div><a href="#" title="Close" class="modal-close">Close</a>
 <h1>Voilà!</h1>
 <div>A CSS-only modal based on the :target pseudo-class. Hope you find it helpful.</div>
 </div>
 </div>

{%- for testimonial in module.testimonial -%}
<div class="pwr-rich-text pwr-testimonial__quote">
{{ testimonial.quote }} <a href="#test">Read More</a> </div>
{%- endfor -%}

```

Hopefully this makes sense and thanks in advance!

---

<div class="post-metadata">

**Author:** ![Mike\_Eastwood](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mike_eastwood/32/70075_2.png) [@Mike\_Eastwood](https://community.hubspot.com/u/Mike_Eastwood)\
**Post date:** [April 17, 2024, 7:58pm UTC](https://community.hubspot.com/t/testimonial-slider-with-modal-using-hubl-for-loop/105064/2 "2024-04-17T19:58:26Z")

</div>

Hi @cives

If I understood what you meant you can use [Hubl to set variables, then call them later.](https://developers.hubspot.com/docs/cms/hubl/variables-macros-syntax#variables)

```auto
{% set string_var = "This is a string value stored in a variable" %}
{{ string_var}}

```

Is this what you meant?

Mike

Here to learn more about HubSpot and share my HubSpot Knowledge. I’m the founder of [Webalite](https://www.webalite.com?utm_campaign=community-forum&utm_source=community&utm_content=signature) a Gold HubSpot Partner Agency based in Wellington, New Zealand and the founder of **Portal-iQ** the world’s first automated [HubSpot Portal Audit](https://portal-iq.com?utm_campaign=community-forum&utm_source=community-forum&utm_content=signature) that helps you work smarter with HubSpot.

---

<div class="post-metadata">

**Author:** ![cives](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cives/32/57633_2.png) [@cives](https://community.hubspot.com/u/cives)\
**Post date:** [April 17, 2024, 8:03pm UTC](https://community.hubspot.com/t/testimonial-slider-with-modal-using-hubl-for-loop/105064/3 "2024-04-17T20:03:29Z")

</div>

The section of the module that needs the string\_var occurs before the loop it would get the information from, any guidance on how to handle this?

---

<div class="post-metadata">

**Author:** ![Mike\_Eastwood](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mike_eastwood/32/70075_2.png) [@Mike\_Eastwood](https://community.hubspot.com/u/Mike_Eastwood)\
**Post date:** [April 18, 2024, 10:16pm UTC](https://community.hubspot.com/t/testimonial-slider-with-modal-using-hubl-for-loop/105064/4 "2024-04-18T22:16:55Z")

</div>

Hey @cives

Have a rummage around this page, particularly the [require\_js](https://developers.hubspot.com/docs/cms/building-blocks/modules/files#require-js-block) block.

Does that do what you want?

Mike
