Reuse data from repeating region

  • Hi guys,

    I have a repeating region on a page and I want to use the data from that region in another repeating region within JavaScript at the bottom of the page. How can I do that?

    This is my page:

    And this is my template:

    1. <div class="song amplitude-song-container amplitude-play-pause" data-amplitude-song-index="<perch:content id="perch_item_zero_index" type="hidden">">
    2. <div class="song-meta-data">
    3. <span class="song-title"><perch:content type="text" id="TuneTitle" label="Title" order="1" required ></span>
    4. <span class="song-artist"><perch:content type="text" id="TuneArtist" label="Artist" order="2" required></span>
    5. <span class="song-duration"><perch:content type="text" id="TuneTime" label="Time" order="3" required help="Enter time in format 0:00"></span>
    6. </div>
    7. </div>
    8. <span class="song-download">
    9. <a href="<perch:content id="file" type="file" label="File" order="4">" download></a>
    10. </span>



  • drewm

    Approved the thread.
  • Hi Robert

    You can move the script into a perch template and then pass the same region through a perch_content_custom function.

    This is a bit rough and untested but hopefully it gives you an idea on how to get started:

    1. perch_content_custom('Playlist', [
    2. 'template' => 'song_script.html',
    3. ]);

    The perch:showall will display all the regions available to you at runtime. You can delete it when you are done.

    If you want to add numerical counting etc to the titles then there are special ids available to you. They are listed here.