开发者

Pagination in modx revolution with different page limits for different pages

开发者 https://www.devze.com 2023-04-05 00:02 出处:网络
I was working with getResources and getPages for pagination. Now, I have a requirement that the first page h开发者_Python百科as 6 child Resources and the further pages have 9 child Resources each. I t

I was working with getResources and getPages for pagination. Now, I have a requirement that the first page h开发者_Python百科as 6 child Resources and the further pages have 9 child Resources each. I tried manipulating with the limit parameter, but didn't get the results. Is there some way or the other to do the thing using getResources and getPages? Any other method that can be helpful as well.

Thanks in advance.


&pageOneLimit can be used to set different page limit for first page. it is added in the get page version 1.2.2-pl.so upgrade it use it..

[[!getPage? &element=getResources &limit=9 &pageOneLimit=6 &tpl=whatever ]]


you can pass a parameter via GET in a URL link to the page to allow the user to select between viewing 10, 20, or all results.

<a href="[[~[[*id]]? &limit=`10`]]">see 10 per page</a> | 
<a href="[[~[[*id]]? &limit=`20`]]">see 20 per page</a> |
<a href="[[~[[*id]]? &limit=`0`]]">see all</a>

Where [[*id]] is the page that you're on which contains the "getPage" snippet call.


go to rtfm.modx.com and lookup "IF" under the plugins - it's basically an if statement for modx tags. I would think that maybe you could find some condition within your pages that you could set your getresources limit on. basically :

[[!getResources? &limit=`[[!if? &subject=`[[+currentpage]]` &operator=`!=` &operand=`1` then=`6` &else=`9`]]` &tpl=`whatever`]]

You'll have to check the syntax - I just winged that off the top of my head & also you'll have to investigate how the pagination figures out what page it's on to get the correct variable for the subject - but I think you should be able to do it like that.

-sean

UPDATE

You could probably do it like this:

[[!getPage? &element=getResources &limit=[[!if? &subject=[[+page]] &operator=!= &operand=1 &then=6 &else=9 ]] &tpl=whatever ]]

However getPage also has a limit attribute & I have no idea how it differentiates between it's attributes and it's element attributes. The docs appear to be confusing here. The +page variable is default as in the docs & it looks like you can change it with the pageVarkey attribute. Again, off the top of my head, check the syntax and docs before trying.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号