Can getYoutube use getPage for pagination?

Greetings All,

I had no trouble using the excellent getYoutube snippet to embed the videos from my YouTube channel into a page of the website I am developing. However the pagination that is built into getYoutube is not as robust as I would prefer, and I would like the video pagination to match the rest of my site. I found this post from Mark Hamstra, but after reading it, I am at a loss as to how to modify the getYoutube snippet to play nicely with getPage. Any help would be sincerely appreciated.

Glancing at the code, the snippet already sets the “total” placeholder and reads the “limit” property.

So I suppose the only thing you have to change is to also read the “offset” property, and to change the value of $pageToken accordingly instead of using this line:

1 Like

Thanks for taking the time to respond to my question. It is much appreciated. I assume I can read the offset property by adding this line:

$offset = $modx->getOption('offset',$scriptProperties,0);

Do you have a suggestion for how would I need to change the value of $pageToken? The getYoutube snippet is generating pagenames that look something like this:

...videos.html?page=CA8QAA

and, as I am sure you are aware, getPage pagenames are simply sequentially numbered in this fashion:

...videos.html?page=2

Again, thank you for the help. Hopefully one day I will have the time to learn how to truly understand php!

Oops! I didn’t look at the API close enough.
This makes the matter much more complicated.

One possible solution would be to query all the data once and save it to the cache.
Then on a request just return the correct portion of the data from the cache.

Another way may be to just save the values of the different pageTokens to the cache.

You probably have to take a look at Custom Caching in MODX.