ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Pagination not working as expected with exp:file:entries tag pair

October 12, 2012 6:57am

Subscribe [1]
  • #1 / Oct 12, 2012 6:57am

    Pete Eveleigh

    31 posts

    When using exp:file:entries to output a list of files from a directory the pagination system does not work properly unless dynamic=“on”.

    In order to list all the files from the directory (i.e. without a category   url segment) one must use dynamic=“off” or dynamic=“no”.

    I need to use dynamic=“no” to show a list of ALL files if no category or other dynamic info is being provided - as is standard practice.

    It is possible to “work around” the problem by adding an additional url segment before the pagination segment.

    For example, when listing 10 files at a time;

    mysite.com/resources/P10  will incorrectly show the first 10 files (regardless of whether the third segment is P10, P20, P30)

    whereas;

    mysite.com/resources/foo/P10 will correctly show files 11-20

    Sample code that demonstrates the problem:

    {exp:file:entries directory_id="7" dynamic="no" limit="10" paginate="bottom"}
     <h3>{title}</h3>
    <p> {if description}{description}{/if}<br />
     <a href="http://{file_url}">Download</a><br />
     Categories: {categories backspace="6"}<a href="http://{path=resources}">{category_name}</a>, {/categories}</p>
    
    <p> {paginate}<br />
            Page {current_page} of {total_pages} pages {pagination_links}<br />
        {/paginate}</p>
    
    <p> {if no_results}<br />
     There are no resources in this category.<br />
     {/if}<br />
    {/exp:file:entries}

    If I change the opening tag to

    {exp:file:entries directory_id="7" dynamic="no" limit="10" paginate="bottom" paginate_base="resources/foo"}

    Then the problem disappears, although I now have duplicated content since /resources returns the same page as /resources/foo (which I really don’t want).


    However, if the dynamic parameter is set to “on” or “yes”, for example when using categories, the pagination works properly.


    I need to do some further testing before I submit a bug report but thought I’d post this here in case anyone can see something I’m doing wrong.

    Note: the same methods that I’m using here work perfectly well when using {exp:channel:entries} so I don’t think I’m using categories/pagination incorrectly in my templates.

     

  • #2 / Oct 15, 2012 10:37am

    Robin Sowell

    13255 posts

    Hi Pete- what version of EE are you running?  I’m not replicating on the latest- it paginates for me in either url case. 

    And just so I’m clear- you want dynamic off except for pagination- correct?  So, ignoring anything in the URL except the Px.

  • #3 / Oct 16, 2012 4:11am

    Pete Eveleigh

    31 posts

    The site is running 2.5.2 at the moment (planning to update asap, not had chance to yet)

    And yes, I want dynamic off so it lists all files and then ‘on’ so it can list categories of files.

    I will PM you a link to the dev site so you can see what I’m doing.


    EDIT: Can’t PM you as it’s saying your inbox is full.

  • #4 / Oct 17, 2012 10:07am

    Robin Sowell

    13255 posts

    Sorry about that, Pete.  I keep PM’s turned off to keep things to email.  Which- I just sent you one.  It may be fastest if we can go in and take a look.  I don’t THINK there have been any changes that would affect it since 2.5.2, so I won’t push the upgrade for this one.

  • #5 / Oct 18, 2012 4:19am

    Pete Eveleigh

    31 posts

    No probs.

    I’ve received your request for login details. I can’t provide them just yet as we are in the final stages before launch and the client is checking things. Since I’ve got the workaround in place to all intents and purposes the site is working - just not as I’d desire - so we are OK for the moment.

    Once he’s done and the site is live I will send over the access info to you and we can try to work out if it’s something that needs fixing in the Core. Should be Monday/Tuesday.

    Thanks for your help

  • #6 / Oct 18, 2012 9:34am

    Robin Sowell

    13255 posts

    Sounds like a plan.  Is weird- I’m probably just missing something in the testing.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases