WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Gallery
[feature] Limit and paginate Galleries shown in Albums (25 posts)

  1. Jacotheron
    Member
    Posted 10 months ago #

    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

    http://wordpress.org/plugins/nextgen-gallery/

  2. paradiselost79
    Member
    Posted 9 months ago #

    Please let me know if you have found an answer for this, would be extremely helpful.

  3. photocrati
    Member
    Plugin Author

    Posted 9 months ago #

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

    Thanks!

    - Cais.

  4. Jacotheron
    Member
    Posted 9 months ago #

    @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.

  5. paradiselost79
    Member
    Posted 9 months ago #

    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.

  6. paradiselost79
    Member
    Posted 9 months ago #

    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...

  7. tizz
    Member
    Posted 9 months ago #

    @ 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.

  8. tizz
    Member
    Posted 9 months ago #

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

  9. Jacotheron
    Member
    Posted 9 months ago #

    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).

  10. Jacotheron
    Member
    Posted 9 months ago #

    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.

  11. paradiselost79
    Member
    Posted 9 months ago #

    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.

  12. tizz
    Member
    Posted 9 months ago #

    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.

  13. paradiselost79
    Member
    Posted 9 months ago #

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

  14. tizz
    Member
    Posted 9 months ago #

    @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.

  15. paradiselost79
    Member
    Posted 9 months ago #

    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?

  16. photocrati
    Member
    Plugin Author

    Posted 9 months ago #

    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: http://wordpress.org/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).

  17. paradiselost79
    Member
    Posted 9 months ago #

    @tizz, I still cannot get a button to show to go to next page. I can limit the number shown on the primary page, but there is not button to move on. Is there a default one that should show, or one I should add? Not terribly familiar with in depth php

  18. Jacotheron
    Member
    Posted 9 months ago #

    Step 1 fixes the url when you are on a page other than 1 (as nextgen generates a url ending with 'nggallery/page/N' and we actually need 'page/N') by removing the current page's 'page/N' part, so that step 2 will generate the correct url.

    Step 2 removes the 'nggallery/' part of the generated url (the "$this->object->set_param_for($current_url, 'page', $newpage) generates the url"). This have to be done on 3 lines:

    //line 39 in original file; ~47 in my file
    $return['prev'] = $this->object->set_param_for($current_url, 'page', $newpage);
    ...
    //line 56 in original file; ~64 in my file
    $link = $this->object->set_param_for($current_url, 'page', $newpage);
    ...
    //line 66 in original file; ~74 in my file
    $return['next'] = $this->object->set_param_for($current_url, 'page', $newpage);

    In all of the above lines, the "$this->object->set_param_for($current_url, 'page', $newpage)" should become "str_replace('/nggallery/','/',$this->object->set_param_for($current_url, 'page', $newpage))"

    Step 3 is the part that makes nextgen render the pagination for the 1st page.

    Step 4 handles the limit as well as making nextgen handle the different pages.

    Also something that may cause the navigation to not render is, you need to select a template (in the attach to post interface). Without it, the if statement in "adapter.nextgen_basic_album_controller.php" line 92 will not be satisfied causing it to render in Legacy mode - I have not delved into that part.

    I hope this clears everything up and helps somebody.

    @photocrati thanks for the info. I hope this makes it into nextgen asap without the need for my hack.

  19. isis
    Member
    Posted 9 months ago #

    thanks so much @Jacotheron for the fix.

    i've mentioned the issue of the missing ngg_paged_Galleries and referenced where the functions were in two separate threads over the past two weeks and instead of getting responses those threads were deleted! O_o

    i've been fighting with getting the URLs to work, so hopefully, this does for me, as well!
    if not, definitely a step in a much better direction than i was heading...

  20. photocrati
    Member
    Plugin Author

    Posted 8 months ago #

    @Jacotheron - We appreciate your support in these forums in helping other users! :) We do have it on our agenda and it will hopefully be re-added in one of the next updates.

    Thanks again! (Becky)

  21. paradiselost79
    Member
    Posted 8 months ago #

    Any info on this update? Would love to see it, working on the workaround and just cannot seem to get it to run right.

  22. paradiselost79
    Member
    Posted 8 months ago #

    @Jacotheron - Got pagination, got the galleries limited to 9, the pages are rendering how you say they should (without the nggallery part, just getting 'page/2?page_id=350/'), but getting a 404 error. BTW, you were right about the attaching a template part. I just had to attach a template and I got the nav.

  23. paradiselost79
    Member
    Posted 7 months ago #

    This is the problem I get. The pagination nav shows up, the limit to 9 galleries takes place, but when I click on page 2 I get a 404. Looked at url's, and it comes out really weird. Here is example:
    Actual WP page (it is because client setup some odd security on their site):
    http://www.thebrightwells.com/level2/wplatest/?page_id=350

    But when click on nav for page 2, this is resulting site:
    http://www.thebrightwells.com/level2/wplatest/level2/wplatest/page/2?page_id=350/

    If you want to try, here is a guest login:
    user: guest
    pw: bright22well

    Any ideas? @photocrati, idea when update may allow pagination?

  24. TonisNightOut
    Member
    Posted 2 months ago #

    Hi, Is there any progress or update on this thread?

  25. photocrati
    Member
    Plugin Author

    Posted 2 months ago #

    @TonisNightOut - This topic is very old, if you are seeing an issue with your NextGEN Gallery installation it most likely should be treated as a new topic.

    Please create one with your site specifics and the details of the issue you are seeing.

    Thanks!

    - Cais.

Reply

You must log in to post.

About this Plugin

About this Topic