Subpages don't show values defined in text file

I hope it’s ok if I post this question here.

I’m trying to update the content for one of the ‘bett’ products using the kirby panel but the update only takes effect when I update the betten.txt file which looks like this:

Title: Betten

----

Accordiontiteleins: Product Information

----

Accordionbeschreibungeins: Quality Wood

----

Accordiontitelzwei: Technical Details

----

Accordionbeschreibungzwei: Measurements are 200x90

----

The disadvantage here is that any update to the betten.txt file will apply to all the other bed products which is not desirable since each bed has a different description i.e. Beschreibung.

Now, each bed has a folder with the name of the bed which contains the image of that particular bed and a bett.txt file.

The bett.txt. file looks like this:

Title: Grün Einzelbett

----

Name: Grün Einzelbett

----

Beschreibung: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

----

Accordiontiteleins: Product Information

----

Accordionbeschreibungeins: Quality Wood

----

Accordiontitelzwei: Technical Details

----

Accordionbeschreibungzwei: Measurements are 200x90

----

Accordiontiteldrei: 

----

Accordionbeschreibungdrei: 

----

Files: 

----

Uuid: KWrJHg70LZC7WDEQ

The folder structure looks like this: content/bett/green_bed

This is the code for the template betten.php

<!-- ======= Products No. 2 ======= -->

<article class="beds">
    <?php if ($p = page('bett')) : ?>
        <?php foreach ($p->children()->limit(26) as $bett) : ?>
            <div class="beds-box">
                <!-- Add data attributes to store image, name, and beschreibung -->
                <a href="#" class="popup-trigger" data-image="<?= $bett->image()->url() ?>" data-name="<?= $bett->title()->html() ?>" data-beschreibung="<?= $bett->beschreibung()->html() ?>">
                    <?php if ($image = $bett->image()) : ?>
                        <img src="<?= $image->url() ?>" class="clickable-image">
                    <?php endif ?>
                </a>
                <div class="beds-box-title">
                    <h3><?= $bett->title()->html() ?></h3>
                </div>
            </div>
        <?php endforeach ?>
    <?php endif ?>
</article>

<!-- The modal HTML Structure -->

<div id="myModal" class="popupSlider">
    <span class="closeButton" id="closeSlider">&times;</span>
    <div class="slider-Content">
        <span class="arrow leftArrow" id="prevSlide">&#10094;</span>
        <span class="arrow rightArrow" id="nextSlide">&#10095;</span>

        <!-- ======= Single ======= -->

        <div class="single-product">
            <div class="the-product">
                <img id="popup-image" src="" alt="Popup Image" class="slida">
            </div>
            <div class="product-description">
                <ul class="breadcrumb">
                    <?php foreach ($site->breadcrumb() as $crumb) : ?>
                        <li<?php e($crumb->isActive(), ' aria-current="location"') ?>><a href="<?= $crumb->url() ?>"><?= $crumb->title()->html() ?></a></li>
                        <?php endforeach; ?>
                </ul>
                <h4 id="popup-name"></h4>
                <p id="popup-beschreibung"></p>

                <!-- ======= Bootstrap Accordion ======= -->

                <div class="accordion accordion-flush" id="accordionFlushExample">
                    <div class="accordion-item">
                        <h2 class="accordion-header" id="flush-headingOne">
                            <button class="accordion-button collapsed bold-accordion-header" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne" aria-expanded="false" aria-controls="flush-collapseOne">
                            <?php echo $page->accordiontiteleins(); ?>
                            </button>
                        </h2>
                        <div id="flush-collapseOne" class="accordion-collapse collapse" aria-labelledby="flush-headingOne" data-bs-parent="#accordionFlushExample">
                            <div class="accordion-body"><?php echo $page->accordionbeschreibungeins(); ?></div>
                        </div>
                    </div>
                    <div class="accordion-item">
                        <h2 class="accordion-header" id="flush-headingTwo">
                            <button class="accordion-button collapsed bold-accordion-header" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseTwo" aria-expanded="false" aria-controls="flush-collapseTwo">
                            <?php echo $page->accordiontitelzwei(); ?>
                            </button>
                        </h2>
                        <div id="flush-collapseTwo" class="accordion-collapse collapse" aria-labelledby="flush-headingTwo" data-bs-parent="#accordionFlushExample">
                            <div class="accordion-body"><?php echo $page->accordionbeschreibungzwei(); ?></div>
                        </div>
                    </div>

And this is the jQuery for the slideshow:

// jQuery Popup Slideshow Code for Produkt Übersicht Pages

$(document).ready(function () {
  // Initialize variables
  var images = $(".clickable-image");
  var currentIndex = 0;

  // Function to open the modal and display the image, name, and beschreibung 
  function openModal(index, name, beschreibung) {
    if (index >= 0 && index < images.length) {
      var imgUrl = $(images[index]).attr("src");
      $("#popup-image").attr("src", imgUrl);
      $("#popup-name").text(name);
      $("#popup-beschreibung").text(beschreibung);
      $("#myModal").css("display", "block");
      currentIndex = index;
    }
  }

  // Function to navigate to the next item
  function nextItem() {
    var nextIndex = currentIndex + 1;
    var nextTrigger = $(".popup-trigger").eq(nextIndex);
    if (nextTrigger.length > 0) {
      var name = nextTrigger.attr("data-name");
      var beschreibung = nextTrigger.attr("data-beschreibung");
      openModal(nextIndex, name, beschreibung);
    }
  }

  // Function to navigate to the previous item
  function prevItem() {
    var prevIndex = currentIndex - 1;
    var prevTrigger = $(".popup-trigger").eq(prevIndex);
    if (prevTrigger.length > 0) {
      var name = prevTrigger.attr("data-name");
      var beschreibung = prevTrigger.attr("data-beschreibung");
      openModal(prevIndex, name, beschreibung);
    }
  }

  // Click event handlers to open the modal with name and beschreibung
  $(".popup-trigger").click(function (e) {
    e.preventDefault();
    var index = $(".popup-trigger").index(this);
    var name = $(this).attr("data-name");
    var beschreibung = $(this).attr("data-beschreibung");
    openModal(index, name, beschreibung);
  });

  // Click event handlers for next and previous buttons
  $("#nextSlide").click(nextItem);
  $("#prevSlide").click(prevItem);

  // Close the modal when the close button is clicked
  $(".closeButton").click(function () {
    $("#myModal").css("display", "none");
  });

  // Close the modal when clicking outside the modal content
  $(window).click(function (event) {
    if (event.target == $("#myModal")[0]) {
      $("#myModal").css("display", "none");
    }
  });
});

I’ve attached a screenshot from the control panel for a particular product. Any change I make here won’t take effect.

This is the screenshot

And this is the content of the bett.yml file:

title: Bett
num: zero

status:
  draft: true
  listed: true

fields:
  Name:
    label: Produkt Name
    type: text

  Beschreibung:
    label: Beschreibung
    type: text

  Accordiontiteleins:
    label: Accordion Titel Nr. 1
    type: text

  Accordionbeschreibungeins:
    label: Accordion Beschreibung Nr. 1
    type: text

  Accordiontitelzwei:
    label: Accordion Titel Nr. 2
    type: text

  Accordionbeschreibungzwei:
    label: Accordion Beschreibung Nr. 2
    type: text

  Accordiontiteldrei:
    label: Accordion Titel Nr. 3
    type: text

  Accordionbeschreibungdrei:
    label: Accordion Beschreibung Nr. 3
    type: text

  files:
    label: Bilder
    type: files
    template: image

Can someone please, guide me in the right direction or give me a hint?

The 0_green-bed folder which lives inside the bett folder contains the image of the bed, a bett.txt file and a green-bed-png.txt file.

The bett.txt file has the following:

Title: Green Bed

----

Name: Green Bed

----

Beschreibung: Produktbeschreibung

----

Accordiontiteleins: Product Information

----

Accordionbeschreibungeins: Technical Information

----

Accordiontitelzwei: 

----

Accordionbeschreibungzwei: 

----

Accordiontiteldrei: 

----

The green-bed-png.txt file has: Uuid: vThogHPtkgIMo3so

I was able to solve it by modifying the JavaScript code. I was thinking the yml file would output the data entered in the Kirby panel. Not without JavaScript in this case.

Although it did work, I’m not sure if this is the right way to go about it. I was expecting the yml files to output the data using for example a php ?php echo $page->titeleins(); ?> code without having to add code to the JavaScript file to output it. Grateful for your opinion or any ideas or tips you might have.

Honestly, I have no idea what you are talking about. .yml file are blueprints for the forms in the Panel. They don’t output anything.

Yes, I understand that they are for the panel that’s why I mentioned yesterday that the only way to output the data is via the betten.txt file which results in the data being the same for all the slides even though they are different. This is the problem.

Each bed product has a a folder with its name and inside this folder we have the image of the bed and a bed.txt file which looks like this:

Accordionbeschreibungeins: products

----

Accordiontitelzwei: Product

----

Accordionbeschreibungzwei: Technical Information

----

But the values are not being outputted even though I’ve ?php echo $page->titeleins(); ?> in the template. I hope this helps clarifies things better.

The $page variable always refers to the current page, so if you are on the parent, it will render the content of the parent.

To clarify things more, ?php echo $page->accordiontitelzwei(); ?> which is inside the betten.php template should output the value: ‘Product’. And this is not working.

To put it very simply:

  1. You are on betten page,
  2. you use $page,
  3. so you get was is in betten, not bett.

I’ll be happy to explain this in more detail.

I’ve a betten.php file that lives inside the templates folder. This file looks like this:

<?php snippet('header') ?>

<!-- ======= Introduction ======= -->

<div class="main-container">
    <main>
        <h1>Introduction</h1>
        <p>My text comes here
        </p>
    </main>
</div>

<!-- ======= Products No. 2 ======= -->

<article class="beds">
    <?php if ($p = page('bett')) : ?>
        <?php foreach ($p->children()->limit(26) as $bett) : ?>
            <div class="beds-box">
                <!-- Add data attributes to store image, name, and description -->
                <a href="#" class="popup-trigger" data-image="<?= $bett->image()->url() ?>" data-name="<?= $bett->title()->html() ?>" data-beschreibung="<?= $bett->beschreibung()->html() ?>" data-accordionbeschreibungeins="<?= $bett->accordionbeschreibungeins()->html() ?>" data-accordionbeschreibungzwei="<?= $bett->accordionbeschreibungzwei()->html() ?>">
                    <?php if ($image = $bett->image()) : ?>
                        <img src="<?= $image->url() ?>" class="clickable-image">
                    <?php endif ?>
                </a>
                <div class="beds-box-title">
                    <h3><?= $bett->title()->html() ?></h3>
                </div>
            </div>
        <?php endforeach ?>
    <?php endif ?>
</article>

<!-- Adds the modal HTML structure -->

<div id="myModal" class="popupSlider">
    <span class="closeButton" id="closeSlider">&times;</span>
    <div class="slider-Content">
        <span class="arrow leftArrow" id="prevSlide">&#10094;</span>
        <span class="arrow rightArrow" id="nextSlide">&#10095;</span>

        <!-- ======= Single ======= -->

        <div class="single-product">
            <div class="the-product">
                <img id="popup-image" src="" alt="Popup Image" class="slida">
            </div>
            <div class="product-description">
                <ul class="breadcrumb">
                    <?php foreach ($site->breadcrumb() as $crumb) : ?>
                        <li<?php e($crumb->isActive(), ' aria-current="location"') ?>><a href="<?= $crumb->url() ?>"><?= $crumb->title()->html() ?></a></li>
                        <?php endforeach; ?>
                </ul>
                <h4 id="popup-name"></h4>
                <p id="popup-beschreibung"></p>

                <!-- ======= Bootstrap Accordion ======= -->

                <div class="accordion accordion-flush" id="accordionFlushExample">

                    <!-- Accordion 1 -->

                    <div class="accordion-item">
                        <h2 class="accordion-header" id="flush-headingOne">
                            <button class="accordion-button collapsed bold-accordion-header" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne" aria-expanded="false" aria-controls="flush-collapseOne">
                                Produktinfos
                            </button>
                        </h2>
                        <div id="flush-collapseOne" class="accordion-collapse collapse" aria-labelledby="flush-headingOne" data-bs-parent="#accordionFlushExample">
                            <div class="accordion-body"><span id="popup-accordionbeschreibungeins"></span></div>
                        </div>
                    </div>

                    <!-- Accordion 2 -->

                    <div class="accordion-item">
                        <h2 class="accordion-header" id="flush-headingTwo">
                            <button class="accordion-button collapsed bold-accordion-header" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseTwo" aria-expanded="false" aria-controls="flush-collapseTwo">
                                Oberfläche
                            </button>
                        </h2>
                        <div id="flush-collapseTwo" class="accordion-collapse collapse" aria-labelledby="flush-headingTwo" data-bs-parent="#accordionFlushExample">
                            <div class="accordion-body"><span id="popup-accordionbeschreibungzwei"></span></div>
                        </div>
                    </div>

                    <!-- Accordion 3 -->

                    <div class="accordion-item">
                        <h2 class="accordion-header" id="flush-headingThree">
                            <button class="accordion-button collapsed bold-accordion-header" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseThree" aria-expanded="false" aria-controls="flush-collapseThree">
                                Holzarten
                            </button>
                        </h2>
                        <div id="flush-collapseThree" class="accordion-collapse collapse" aria-labelledby="flush-headingThree" data-bs-parent="#accordionFlushExample">
                            <div class="accordion-body">

                                <!-- ======= Product Palette  ======= -->

                                <div class="product-palette">
                                    <div class="palette-box">
                                        <div class="image-container">
                                            <h3>Aiche</h3>
                                            <img src="content/Bu9X6gok0.jpg">
                                        </div>

                                        <div class="image-container">
                                            <h3>Aiche</h3>
                                            <img src="content/Bu9X6gok0.jpg">
                                        </div>

                                        <div class="image-container">
                                            <h3>Buche</h3>
                                            <img src="content/Bu9X6gok0.jpg">
                                        </div>
                                    </div>

                                    <div class="palette-box">
                                        <div class="image-container">
                                            <h3>Birke</h3>
                                            <img src="content/Bu9X6gok0.jpg">
                                        </div>

                                        <div class="image-container">
                                            <h3>Kunstholz</h3>
                                            <img src="content/Bu9X6gok0.jpg">
                                        </div>

                                        <div class="image-container">
                                            <h3>Plastik</h3>
                                            <img src="content/Bu9X6gok0.jpg">
                                        </div>
                                    </div>

                                    <div class="palette-box">
                                        <div class="image-container">
                                            <h3>Metal</h3>
                                            <img src="content/Bu9X6gok0.jpg">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- ======= Product Palette Stoffe ======= -->

                    <!-- Accordion 4 -->

                 
                </div>
                <a class="button-two" href="/kontakt"><?php echo $site->mehr(); ?> </a>
            </div>
        </div>
    </div>
</div>

<!-- ======= Snippets ======= -->

<?php snippet('info-block') ?>
<?php snippet('footer') ?>

When a visitor visits the bett.php page, they will see a list of all the different bed products that are available. When they click on any bed, a modal slideshow/gallery will popup with a picture of the bed and detailed information about this particular bed. This modal slideshow/gallery allows the visitor to click on the the forwards/backwards arrows to go through the different beds. The modal has a close button to close it which returns the visitor to the bett.php page with the listed beds.

Inside the content folder, we have a ‘bett’ folder. Inside this ‘bett’ folder we have many folders named after the different bed names e.g. greenbed folder, nature bed folder, etc.

Inside the greenbed folder for example, we have:

  1. An image of the greenbed,
  2. A file called ‘greenbed.png.txt’ which just contains ‘Uuid: vThogHPtkgIMo3so’, and
  3. A bed.txt file which looks like this:
Title: Green Bed

----

Name: Green Bed

----

Beschreibung: Lorum ipsum text.

----

Accordiontiteleins: Produktinformation

----

Accordionbeschreibungeins: Natural wood products

----

Accordiontitelzwei: 

----

Accordionbeschreibungzwei: 

----

Accordiontiteldrei: 

----

Accordionbeschreibungdrei: 

----

Accordiontitelvier: 

----

Accordionbeschreibungvier: 

----

Paletteone: Aiche

----

Files:

- file://vThogHPtkgIMo3so
- file://AgRSs4lb6dBfWzeo

----

Uuid: oTRUp5kbWWqBDF0w

Now, let’s suppose I want to update the

Aiche

using php. I’ll put ?php echo $page->Paletteone(); ?> in the desired place inside the betten.php. When I go to the Kirby panel and I type the value in the paletteone filed (which has been created using the bett.yml file), the value is stored in the bett.txt file like this:

Paletteone: Aiche

----

The problem is that while the value is being stored inside the bett.txt file (which lives inside the greenebd folder), it is not being outputted on the front end i.e. on the modal slideshow, even though we have placed ?php echo $page->paletteone(); ?> in the desired place inside the betten.php template.

The YML file is called bett.yml and lives inside the pages folder which lives inside the Blueprints folder (Blueprints/pages/bett.yml). This bett.yml file looks like this:

title: Bett
num: zero

status:
  draft: true
  listed: true

fields:
  Name:
    label: Produkt Name
    type: text

  Beschreibung:
    label: Beschreibung
    type: text

  Accordiontiteleins:
    label: Accordion Titel Nr. 1
    type: text

  Accordionbeschreibungeins:
    label: Accordion Beschreibung Nr. 1
    type: text

  Accordiontitelzwei:
    label: Accordion Titel Nr. 2
    type: text

  Accordionbeschreibungzwei:
    label: Accordion Beschreibung Nr. 2
    type: text

  Accordiontiteldrei:
    label: Accordion Titel Nr. 3
    type: text

  Accordionbeschreibungdrei:
    label: Accordion Beschreibung Nr. 3
    type: text

  Accordiontitelvier:
    label: Accordion Titel Nr. 4
    type: text

  Accordionbeschreibungvier:
    label: Accordion Beschreibung Nr. 4
    type: text

  paletteone:
    label: Palette Nr. 1
    type: text

  files:
    label: Bilder
    type: files
    multiple: true # Allow multiple images
    template: image

Now, since the values are not being outputted as they normally should on the front end, I had to leverage JavaScript to output values. An example is the which you can see in the betten.php template. Normally, I’ll use <span ?php echo $page->accordionbeschreibungeins(); ?> to output the value, but since the value is not bein outputted on the front end, I had to use . While this method does output the value, it’s time consuming since it requires me to update the JavaScript file each time I need to add a new value.

Here the JavaScript I have:

$(document).ready(function () {
  // Initialize variables
  var images = $(".clickable-image");
  var currentIndex = 0;

  // Function to open the modal and display the image, name, beschreibung, and accordiontiteleins
  function openModal(
    index,
    name,
    beschreibung,
    accordionbeschreibungeins,
    accordionbeschreibungzwei
  ) {
    if (index >= 0 && index < images.length) {
      var imgUrl = $(images[index]).attr("src");
      $("#popup-image").attr("src", imgUrl);
      $("#popup-name").text(name);
      $("#popup-beschreibung").text(beschreibung);
      // Update the accordion title here
      $("#popup-accordionbeschreibungeins").text(accordionbeschreibungeins);
      $("#popup-accordionbeschreibungzwei").text(accordionbeschreibungzwei);
      $("#myModal").css("display", "block");
      currentIndex = index;
    }
  }

  // Function to navigate to the next item
  function nextItem() {
    var nextIndex = currentIndex + 1;
    var nextTrigger = $(".popup-trigger").eq(nextIndex);
    if (nextTrigger.length > 0) {
      var name = nextTrigger.attr("data-name");
      var beschreibung = nextTrigger.attr("data-beschreibung");
      var accordionbeschreibungeins = nextTrigger.attr(
        "data-accordionbeschreibungeins"
      );
      var accordionbeschreibungzwei = nextTrigger.attr(
        "data-accordionbeschreibungzwei"
      );
      openModal(
        nextIndex,
        name,
        beschreibung,
        accordionbeschreibungeins,
        accordionbeschreibungzwei
      );
    }
  }

  // Function to navigate to the previous item
  function prevItem() {
    var prevIndex = currentIndex - 1;
    var prevTrigger = $(".popup-trigger").eq(prevIndex);
    if (prevTrigger.length > 0) {
      var name = prevTrigger.attr("data-name");
      var beschreibung = prevTrigger.attr("data-beschreibung");
      var accordionbeschreibungeins = prevTrigger.attr(
        "data-accordionbeschreibungeins"
      );
      var accordionbeschreibungzwei = prevTrigger.attr(
        "data-accordionbeschreibungzwei"
      );
      openModal(
        prevIndex,
        name,
        beschreibung,
        accordionbeschreibungeins,
        accordionbeschreibungzwei
      );
    }
  }

  // Add click event handlers to open the modal with name, beschreibung, and accordiontiteleins
  $(".popup-trigger").click(function (e) {
    e.preventDefault();
    var index = $(".popup-trigger").index(this);
    var name = $(this).attr("data-name");
    var beschreibung = $(this).attr("data-beschreibung");
    var accordionbeschreibungeins = $(this).attr(
      "data-accordionbeschreibungeins"
    );
    var accordionbeschreibungzwei = $(this).attr(
      "data-accordionbeschreibungzwei"
    );
    openModal(
      index,
      name,
      beschreibung,
      accordionbeschreibungeins,
      accordionbeschreibungzwei
    );
  });

  // Add click event handlers for next and previous buttons
  $("#nextSlide").click(nextItem);
  $("#prevSlide").click(prevItem);

  // Close the modal when the close button is clicked
  $(".closeButton").click(function () {
    $("#myModal").css("display", "none");
  });

  // Close the modal when clicking outside the modal content
  $(window).click(function (event) {
    if (event.target == $("#myModal")[0]) {
      $("#myModal").css("display", "none");
    }
  });

  // Click event handler for clickable images in the slider
  $(".clickable-image").click(function (e) {
    e.preventDefault();
    var index = $(".clickable-image").index(this);
    var name = $(this)
      .closest(".beds-box")
      .find(".popup-trigger")
      .attr("data-name");
    var beschreibung = $(this)
      .closest(".beds-box")
      .find(".popup-trigger")
      .attr("data-beschreibung");
    var accordionbeschreibungeins = $(this)
      .closest(".beds-box")
      .find(".popup-trigger")
      .attr("data-accordionbeschreibungeins");
    var accordionbeschreibungzwei = $(this)
      .closest(".beds-box")
      .find(".popup-trigger")
      .attr("data-accordionbeschreibungzwei");
    openModal(
      index,
      name,
      beschreibung,
      accordionbeschreibungeins,
      accordionbeschreibungzwei
    );
  });
});

The betten.txt file is necessary for displaying the betten.php page and contains only this:

Title: Betten

----

Attached is a screenshot of it
Screenshot_20230914_223902

I hope things have become clearer now and please let me know if you need any further clarification. Thank you.

Update: I’ve tried renaming all the files pertaining to the beds categories to ‘betten’ instead of ‘bett’ with no success. I still cannot output data to the front end.

Yes, and it normally works fine on the other page, but not on this particular page that I described. For example: <?php echo $betten->paletteone(); ?> should output the value ‘Aiche’ but it’s not outputting the value.

This is getting too messy for me, you keep introducing new variables that are not used anywhere in the above.

I’ll try to explain the basics one more time…

Assuming a page structure like this:

content/
  parent/
     parent.txt
      child-1/
       child.txt
      child-2/
        child.txt

When you are on the parent page (using paren.php)

<?php snippet('header' ?>
<?= $page->title() // title of parent page, so page always refers to the current page?>
<!— loop through children —>
<?php foreach ($page->children() as $child): ?>
    <!— inside this loop you have access to the child pages using $child, outside this loop you don’t have access to the child!  —>
    <?= $child->title() ?>
     <?= $child->whatever() ?>
<?php endforeach ?>
<?php snippet(‘footer' ?>

Thank you for your support. I’m afraid it has to do with JavaScript. Since the content generation relies on a user interaction i.e. the dynamic data is not available at the time the page is initially rendered, then use of JavaScript is necessary. Since I have a modal that displays content when an image is clicked, and the content is populated dynamically based on the clicked image, then JavaScript is needed to handle these interactions.

Well, if you use JavaScript to show content after initial rendering, you either have to store this data in the page right from the beginning and show/hide depending on user interaction, or you have to fetch the data at interaction time via Ajax.

Hello Ms. Broda,

Quick question, I’m currently learning JSON and AJAX and wanted to know if I need to create a JSON file with the data for the modal slideshow or can I get the data stored in the txt files with AJAX? Thank you

Yes, as I already wrote above.

See also: Load more with Ajax | Kirby CMS

Not your use case, but the basics are always the same.