• In the legacy Nextgen Gallery it was possible to set a variable (somewhere) to make an Album list of galleries paginate (if it have more than X number of galleries inside it).

    On one of my client’s websites, there is an Album with more than 100 Galleries inside it. Basically in this website a gallery is a collection of photos of the same doll (the owner creates life-like dolls). A gallery starts in the Available for Adoption Album, and when adopted, goes to the Adopted Album (thus this one will always have a lot of galleries).

    Using the previous NextGen, I was able to limit the number of displayed Galleries to a manageable number. After the upgrade I have no idea where to go look. What I am asking is a setting for this (maybe in the Gallery Settings > Extended Album).

    Regards
    Jaco

    https://www.ads-software.com/plugins/nextgen-gallery/

Viewing 15 replies - 1 through 15 (of 28 total)
  • Please let me know if you have found an answer for this, would be extremely helpful.

    Plugin Contributor photocrati

    (@photocrati)

    Please feel free to make any Feature Requests on this form: https://www.nextgen-gallery.com/feature-voting/

    Thanks!

    – Cais.

    Thread Starter Jacotheron

    (@jacotheron)

    @photocrati the biggest part of the code to achieve this, is actually already written in the plugin. It appears that due to a bug, it is not yet active.

    I have found the code by looking at filenames:

    1. I found a file called ‘nextgen_basic_album_galleries_per_page.php’ inside folder ‘nextgen-gallery/products/photocrati_nextgen/modules/nextgen_basic_album/templates’ – this file is basically the interface which will allow you to set the number of galleries per page.
    2. Using the names inside this file (doing a Notepad++ Search in Files), I found the file ‘adapter.nextgen_basic_album_controller’ one folder up from previous. At ~ line 78 is where the pagination part is implemented.
    3. By default though the $current_page = 0 (in stead of 1) and the $display_settings[galleries_per_page] = null (not set, showing all)

    I tried implementing it myself (by adding a few lines). I forced it to 9 galleries per page if it is not set, and setting the $current_page to 1 if it is not set. This makes it show only the N number of galleries, as well as navigation to the other pages, but the links does not work.

    Basically the links add a ‘nextgen/page/[pagenr]’ to the album page’s url. When the link is clicked it is not caught and handled by NextGen so it Error 404.

    Unfortunately I have no idea how the plugin works in the background (since there are so many changes from the legacy version) so I have no idea how to catch the url to display the next page of galleries.

    I saw that php as well, and did not know if that was carry over from legacy or something they were working on. @photocrati, any help here appreciated.

    Still no responses anywhere, I have a client that really wants this. The only thing I can think of is to create a bunch of pages, and put specific galleries on each one. Would be very frustrating…

    @ paradiselost79 A quicker and temporary solution may be split the album in more than one, then put their codes in a page divided by many <!–nextpage–> tag as you need.
    This in case that new galleries aren’t added so often, but in case you can easily move them from the Manage album page.

    @ Jacotheron if you are a coder please read here what I wrote, maybe could be the “missing piece” to your interesting findings.

    Thread Starter Jacotheron

    (@jacotheron)

    I am working on a possible fix, which will work while the developers work on the final fix (it will need a few core files edited – which will be replaced at each update until it is in the core).

    Thread Starter Jacotheron

    (@jacotheron)

    Ok, this fix is as follows:

    All files to edit is relative to the “nextgen-gallery\products\photocrati_nextgen\modules\” directory.

    Step 1: ‘nextgen_pagination/mixin.nextgen_basic_pagination.php’ around line 22:
    Code that is currently there:

    if (empty($current_url))
                $current_url = $this->object->get_routed_url(TRUE);

    Add below that:

    $current_url_parts = explode('/',$current_url);
    end($current_url_parts);
    if(prev($current_url_parts) == 'page'){
    array_pop($current_url_parts);
    array_pop($current_url_parts);//remove the last two elements (page/#)
    }//endif
    $current_url = implode('/',$current_url_parts);

    This will make sure that the pagination urls are correct.

    Step 2: same file, 3 lines need changing:
    Find

    $this->object->set_param_for($current_url, 'page', $newpage)

    Replace with

    str_replace('/nggallery/','/',$this->object->set_param_for($current_url, 'page', $newpage))

    This removes the ‘/nggallery/’ from the generated url (as nextgen does not give any images if it is present).

    Step 3: ‘nextgen_gallery_display/class.displayed_gallery.php’ near line 595
    Find

    if ($limit && $offset)

    Should be

    if ($limit !== false && $offset !== false)

    This allows the pagination and limit on an album’s first page (offset will be 0 which equates to false, thus we need to make sure that it really is false and not 0 using the Not Identical Operator).

    Step 4: ‘nextgen_basic_album/adapter.nextgen_basic_album_controller.php’ near line 80:
    Above the comment of line 78 add

    $display_settings['galleries_per_page'] = 9;

    9 Is the number of galleries/albums that may be displayed on a page

    Below

    $current_page = (int)$this->param('page', 1);

    Add

    $current_page = get_query_var('paged');
    if($current_page == ''){ $current_page = 1; }

    This gets the right variables to handle the current page

    You are done. This should do the trick, without breaking anything, however I have only done basic testing to see if it breaks anything.
    This is also a hack and not really a fix (due to the number of changes and overwriting of NextGen variables).

    Unfortunately this does not enable ajax pagination, but this pagination is better than nothing.

    I hope the development team will fix it in an update, but till then we either should not upgrade or re-implement this after each update.

    I also hope this helped someone.

    Awesome, almost there I guess. It displays the set number of galleries I put in the adapter.nextgen_basic_album_controller.php file, but how do I put a ‘Next’/’Previous’ button? Thank you for the awesome help.

    Thanks Jacotheron for your job. I’ve tested your code and pagination works but the part str_replace('/nggallery/','/',$this->object->set_param_for($current_url, 'page', $newpage))
    doesn’t because /nggallery/ is added in the generated URL so galleries aren’t found when you change page.

    @tizz how did you get the next page button to even show?

    @tizz how did you get the next page button to even show?

    With the code of Jacotheron above, but maybe I didn’t understand your question.

    It seems to work in regards to limiting the number of galleries, but I do not see a next page button. Is that in a specific line of the code? Or do I create new pages and put a link at the bottom of each one?

    Plugin Contributor photocrati

    (@photocrati)

    Hey all – this is the third thread on this I’ve seen in the forums today. This functionality used to be available using a custom field called ngg_paged_Galleries.

    I think we just missed this functionality in the big 2.0 update. We’re checking this and if so, we’ll try to add it back and probably try to expose it from the main interface rather than using custom fields.

    Can you all please follow this thread and feel free to ad your voice there as well: https://www.ads-software.com/support/topic/ngg_paged_galleries?replies=5

    We’ll probably just reply on this issue in that specific thread. But I’ll link to this thread from there as well for reference.

    Thanks (Erick).

Viewing 15 replies - 1 through 15 (of 28 total)
  • The topic ‘[feature] Limit and paginate Galleries shown in Albums’ is closed to new replies.