We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20215
    • 144 Posts
    placeholder total is set only in the first page

    
    if (!empty($limit)) $c->limit($limit,$start);
    
    $total = $modx->getCount('galItem',$c); //get total amount for the getPage snippet
    $modx->setPlaceholder('total', $total); // set total amount for the getPage snippet
    
    //in getPage snippet
    
        $totalSet = $modx->getPlaceholder($properties['totalVar']);
    return $modx->getPlaceholder($properties['totalVar']);
    
    //first page return 43 .. second page page=2 return 0
    
    


    How do I solve it?
      ----------------------------------
      canale irc Italiano #modx server: tophost.azzurra.org
      • 20215
      • 144 Posts
      ok solved in this way

      getPage snippet
          $totalSet = $modx->getPlaceholder($properties['totalVar']);
          if(empty($totalSet)){
              $totalSet = $modx->getPlaceholder('gallery.total');
          }
      


        ----------------------------------
        canale irc Italiano #modx server: tophost.azzurra.org
        • 37971
        • 14 Posts
        If you want pagination for thumbs list use getPage snippet call:
        [[!getPage?
            &elementClass=`modSnippet`
            &element=`Gallery` 
            &totalVar=`gallery.total`
            &limit=`6`
            &album=`1`
            &pageVarKey=`page`
            &start=`page`
        ]]
        


        And add in snippet Gallery before
        /* check for REQUEST vars if property set */

        this code:
        if ($start == 'page') {
            $page = ($_GET['page'] ? $_GET['page'] : 1);
            $start = $limit * ($page - 1);
        }
        
        [ed. note: schizoinside last edited this post 12 years, 3 months ago.]
          • 37840
          • 33 Posts
          On my site I would love to add a button that just says "Next Album" or "Previous Album"

          I dont want to have pages for thumbs but for albums.

          To achieve this effect manually i simply have to change the galAlbum number below in my link to cycle the photography page to the next album.
          http://www.antsinmyspacebar.com/modx/barry-oneill-photography.html?galAlbum=9


          Can this be done?

          (sorry if unclear im still a modx n00b)
            • 30491
            • 44 Posts
            For anyone wondering how to get this done in Gallery 1.5.2, i've managed to get it to work with these settings successfully.

            Snippet code:

            
            [[getPage?
                &elementClass=`modSnippet`
                &element=`Gallery` 
                &totalVar=`gallery.total`
                &limit=`4`
                &album=`1`
                &useCss=`0`
                &toPlaceholder=`gallery`]]
            
            


            getPage Snippet, add this line, somewhere after the
            $properties['offset']
            has been set, I choose line 41 and added:

            $properties['start'] = $properties['offset'];


            I found the solution of a Russian modx page and it worked relatively flawlessly http://community.modx-cms.ru/blog/questions/6454.html

            I'm still trying to get it work with &sort variable, for some reason, when sorting the items with &sort = `rand` it repeats some of the items, resulting in incorrect pagination.
              • 41633
              • 13 Posts
              There is another solution without editing getPage snippet source code.
              Step 1. Create wrapper chunk for Gallery snippet [[$gallery_wrapper]]:
              [[!Gallery?  
              &limit=`[[+limit]]`
              &start=`[[+offset]]`
              &album=`your_gallery_id`
              ]]
              

              Step 2. Call getPage snippet with this parameters:
              [[!getPage?
              &elementClass=`modChunk`
              &element=`gallery_wrapper`
              &limit=`5`
              &totalVar=`gallery.total`
              ]]
              
              <div>
              <span>Page [[+page]] of [[+pageCount]]</span>
              [[!+page.nav]]
              </div>
              
                • 42775
                • 1 Posts
                eugen.t's solution works just fine and seems compatible with future updates of the Gallery plugin: 5 stars for it from me.
                • Quote from: bazpaul at Feb 22, 2012, 04:22 AM
                  On my site I would love to add a button that just says "Next Album" or "Previous Album"

                  Could be done by https://github.com/Jako/Gallery/blob/patch-1/core/components/gallery/elements/snippets/snippet.galleryalbums.php

                  and a containerTpl like this:

                  <a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+nav.prev]]`]]">Previous Album</a> | <a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+nav.next]]`]]">Next Album</a>
                  [ed. note: Jako last edited this post 10 years, 7 months ago.]
                    • 46309
                    • 79 Posts
                    Can anybody help me with finding a solution of the second post:
                    http://forums.modx.com/thread/88803/gallery-getpage-pagination-problem#dis-post-488472
                    Thank you in advance!
                      peace&love / bike&ride
                      • 36446
                      • 184 Posts
                      Hi! I tried Eugen T. Solution but the +page.nav thing didn't work out: I put together my calls like this:

                      Quote from: eugen.t at Oct 10, 2012, 09:30 PM
                      There is another solution without editing getPage snippet source code.
                      Step 1. Create wrapper chunk for Gallery snippet [[$gallery_wrapper]]:
                      [[!Gallery?  
                      &limit=`[[+limit]]`
                      &start=`[[+offset]]`
                      &album=`your_gallery_id`
                      ]]
                      

                      Step 2. Call getPage snippet with this parameters:
                      [[!getPage?
                      &elementClass=`modChunk`
                      &element=`gallery_wrapper`
                      &limit=`5`
                      &totalVar=`gallery.total`
                      ]]
                      
                      <div>
                      <span>Page [[+page]] of [[+pageCount]]</span>
                      [[!+page.nav]]
                      </div>
                      

                      Unfortunately i only get 5 Pictures and no "next Page" link and the page count is always 1. Can anyone point me to my mistake? Thanks a lot for helping!


                      EDIT:

                      I found another post and was ablet to get everything working - here is my code (I use prettyGallery)

                      [[!If? &subject=`[[*prettyGalleryAlbum]]` &operator=`!empty` &then=`<div class="pagination">Page [[+page]] of [[+pageCount]] <ul>[[!+page.nav]]</ul></div>`]]
                      [[!If? &subject=`[[*prettyGalleryAlbum]]` &operator=`!empty` &then=`[[!getPage?
                      &elementClass=`modSnippet`
                      &element=`Gallery`
                      &album=`[[*prettyGalleryAlbum]]`
                      &thumbTpl=`prettyGalleryImageTpl`
                      &thumbWidth=`[[*prettyThumbnailWidth]]`
                      &thumbHeight=`[[*prettyThumbnailHeight]]`
                      &useCss=`0`
                      &limit=`15`
                      &totalVar=`gallery.total`
                      ]]`]]
                      [[!If? &subject=`[[*prettyGalleryAlbum]]` &operator=`!empty` &then=`<div style="clear:both"></div>`]]
                      [[!If? &subject=`[[*prettyGalleryAlbum]]` &operator=`!empty` &then=`<div class="pagination">Page [[+page]] of [[+pageCount]] <ul>[[!+page.nav]]</ul></div>`]]

                      [ed. note: flanger last edited this post 9 years, 11 months ago.]
                        https://www.beautyislife-shop.de - premium make-up!
                        https://www.topsterne.de - sell it here!
                        ---------------------------------------------------------