Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Reel ignoring offset parameter in module tag for YouTube

Status Resolved
Add-on / Version Reel 1.3.2
Severity
EE Version 3.5.14

Anthony Stauffer

Mar 07, 2019

Objective:
Using the Reel module tag in a template, fetch the next page of search results for a YouTube search

Problem:
Reel returns the same YT search results, regardless of what the “offset” parameter is set to.

Channels Being Used:
Doesn’t matter, not using a channel

Example:
The following template code produces 3 identical list of search results, even though the offet is increased. Caching is turned off, that is not the issue.


Template Code:

<h4>Offset = 0</h4>
<ul>
    {exp:reel:youtube query="blues"  limit="10" offset="0"}
            <li><strong>{video_id}</strong> - <em>{title}</em></li>
    {/exp:reel:youtube}
</ul>
<hr/>
<h4>Offset = 10</h4>
<ul>
    {exp:reel:youtube query="blues" limit="10" offset="10"}
            <li><strong>{video_id}</strong> - <em>{title}</em></li>
    {/exp:reel:youtube}
</ul>
<hr/>
<h4>Offset = 20</h4>
<ul>
    {exp:reel:youtube query="blues" limit="10" offset="20"}
            <li><strong>{video_id}</strong> - <em>{title}</em></li>
    {/exp:reel:youtube}
</ul>
<hr/>
#1

BoldMinded (Brian)

Thanks, I’ll take a look at it.

#2

BoldMinded (Brian)

It looks like I need to update my documentation b/c offset, or any variant of that, is not supported by the YouTube v3 API. It only supports a nextPageToken. So, in order to do limit=”10” offset=”20” I first have to fetch the first 10 just to get the offset, then do another API call to get the offset of 10 through 20. This isn’t a huge deal to do once or twice, but if someone wanted to do limit=”10” offset=”80”, then there are 7 previous API calls before the relevant call is made.

I’m not sure why you’re needing to do results like that, but you may need to take a different approach b/c I don’t think any practical changes I make to Reel will work. Sorry about that.

#3

Anthony Stauffer

Maybe I’m approaching it the wrong way. What I really want to do is to be able to page through search results, just like in the Reel custom field window. I thought that I was supposed to do that with the offset parameter, but maybe I’m wrong.

When creating an entry that has a Reel field, when you click the button that says “Add Video”, the popup window allows you to search YouTube and page through the results.

So obviously there is code in Reel that does this correctly. All I want is for that functionality to be exposed through a module tag for me to use in my own templates for implementing a YouTube search.

#4

BoldMinded (Brian)

I’ll send a new build later today where the following template logic should work.

<ul>
    {exp:reel:youtube query="blues"  limit="10"}
        <li><strong>{video_id}</strong> {count} of {total_results} out of {absolute_results} - <em>{title}</em></li>
        {if count == total_results}
         {if prev_page}
             <a href="http://?page={prev_page}">Prev</a>
            {/if}
            {if next_page}
             <a href="http://?page={next_page}">Next</a>
            {/if}
        {/if}
    {/exp:reel:youtube}
</ul>

YT’s pagination is token based, so it only knows the next and previous pages. You can’t really skip directly to page 5 of 100 for example.

#5

Anthony Stauffer

That would be perfect, I don’t care about the offset at all, the pagination is all I care about.

Thanks! Anthony

#6

BoldMinded (Brian)

Comment has been marked private.

#7

BoldMinded (Brian)

I’m going to mark this resolved b/c I haven’t heard back in 2 weeks after sending the last build.

Login to reply