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
$totalSet = $modx->getPlaceholder($properties['totalVar']); if(empty($totalSet)){ $totalSet = $modx->getPlaceholder('gallery.total'); }
[[!getPage? &elementClass=`modSnippet` &element=`Gallery` &totalVar=`gallery.total` &limit=`6` &album=`1` &pageVarKey=`page` &start=`page` ]]
/* check for REQUEST vars if property set */
if ($start == 'page') { $page = ($_GET['page'] ? $_GET['page'] : 1); $start = $limit * ($page - 1); }
[[getPage? &elementClass=`modSnippet` &element=`Gallery` &totalVar=`gallery.total` &limit=`4` &album=`1` &useCss=`0` &toPlaceholder=`gallery`]]
$properties['offset']
$properties['start'] = $properties['offset'];
[[!Gallery? &limit=`[[+limit]]` &start=`[[+offset]]` &album=`your_gallery_id` ]]
[[!getPage? &elementClass=`modChunk` &element=`gallery_wrapper` &limit=`5` &totalVar=`gallery.total` ]] <div> <span>Page [[+page]] of [[+pageCount]]</span> [[!+page.nav]] </div>
On my site I would love to add a button that just says "Next Album" or "Previous Album"
<a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+nav.prev]]`]]">Previous Album</a> | <a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+nav.next]]`]]">Next Album</a>
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>
[[!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>`]]