Dynamic Pages

Given two tables [Books] & [Chapters].
I have a page that has a repeater listing the books.
I want to create a page that will display the chapters of the chosen book, one at a time. I am not sure how to filter the [Chapters] tables to respect the book chosen, or to handle [prev][next] that will be necessary. I am guessing I will be using a repeater on a dynamic page.

Are there any similar samples out there?

Hi,

Try looking at an example that shows a category page and an item page. In your case, the chosen book is the item page.
We support next and previous dynamic page actions - you only need to add buttons to your page and connect them to those actions (similar as you would connect a button to a submit action).

Good luck!

Hello Tomer, I answer to this post because it is very close to the problem I actually have.
I have a database which contains videos of songs and i would like them to be organised in a chronological order. How should i do to achieve this knowing that when i sort the lines of my dataset it does not change the gallery thje database is linked to ?

I solved this issue by using a repeater (Lists & Grids) to display the books (cover, blurb, title) and hand coded the click event to dynamically build a url and route to the first chapter. The chapters are displayed on a dynamic item page built from /[booktitle]/[chapterNumber] with hand coded [prev] & [next] buttons that disable when they have reached their respective limits. Functionally, It all works well.

so it means that if i add a “year of the record” in the link i could have them in chronological order ?

I have a column (field) in the database that corresponds to the chapter. The dataset is filtered on that number in ascending order.

At page load, I check to see if the current number is one to set the disabled state of the [prev] button.
At [prev] clicked, I check the current number and subtract one, then route to the prev chapter.

At page load, I check the row count of chapters for the book. If [next] equals row count, I disable [next]
At [next] clicked, I check the current number and add one, then route to the next chapter.

If I add a chapter, it is automatically handled by the queries. So yes, you can play songs in chronological order and add/subtract them at will. The queries for [next] [prev] would be slightly more complex, but doable.

mpotter, what functions are you using for your next and previous buttons? I’m trying to make a comic viewer and the function wixlocation.to doesn’t work to move to a selected page.

I don’t understand how i should do in order to see my videos in the chronological order :frowning: When i sort my data it does not affect the gallery :-/

https://www.hallydayhistory.com/adaptations70-80

Found the solution in wix help, thanks !

This is my code - though it is respective of my data structure.

$w.onReady( function () {

let currentChapter = $w(“#dynamicDataset”).getCurrentItem();
let currentNum = currentChapter[“chapterNumber”];
let url = “/Chapters/” + currentChapter[“bookTitle”].replace(" “,”-“) + “/”
if (currentNum > 1) {
$w(”#prevButton").enable();
$w(“#prevButton”).link = url + (currentNum - 1);
} else {
$w(“#prevButton”).disable();
}

wixData.query("Chapters") 
    .eq("Book title", currentChapter["Book title"]) 
    .count() 
    .then(result => { 

if (currentNum < result) {
$w(“#nextButton”).enable();
$w(“#nextButton”).link = url + (currentNum + 1);
} else {
$w(“#nextButton”).disable();
}
});
});