Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#201 2017-03-20 21:10:34
- alicson
- Member
- Registered: 2004-05-26
- Posts: 465
- Website
Re: etc_pagination: paginate everything
And yes it seems to be frozen again.
I have
<txp:variable name="numPgs"><txp:etc_numpages section="journal,briefs,about,words" pageby="500" /></txp:variable>
<txp:variable name="nopage"><txp:etc_query name="nopage" data="{?numPgs|1|/500.intval.+2}" /></txp:variable>
and
<txp:etc_cache id='dense_archivebydate<txp:etc_query data=''<txp:page_url type="pg" />'' query="$min($|{?nopage}).max($|1)" />'>
textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation
Offline
#202 2017-03-20 21:24:05
- etc
- Developer
- Registered: 2010-11-11
- Posts: 4,079
- Website
Re: etc_pagination: paginate everything
You divide by 500 twice. Try
<txp:variable name="numPgs" value='<txp:etc_numpages section="journal,briefs,about,words" pageby="500" />' />
<txp:etc_query name="nopage" data="{?numPgs|1|.+1}" />
Offline
#203 2017-03-20 21:39:23
- etc
- Developer
- Registered: 2010-11-11
- Posts: 4,079
- Website
Re: etc_pagination: paginate everything
alicson wrote #304948:
For my own sense, is there a reason why an enduser (spam) can make up page numbers and slam the site that way? Or does it generally just not matter, except when one happens to have combinations of pagination and caching set up without having further accounted for queries of miscellaneous imaginary page numbers?
I’m not a behavioral specialist, sorry. :-) In general it does not matter, but in your case etc_cache
will create a record for every encountered (even invalid) pg
value and try to update it later. This will take unnecessary time and space.
And what do the
.max($|0)
vs. the.max($|1)
mean?
Zero was a mistype, sorry. .max($|1)
means for etc_query
the maximum between 1 and the initial data
passed by the chain:
<txp:etc_query data="2" query="$*2.+1.max($|3)" />
reads as 2 -> 2*2=4 -> 4+1=5 -> max(5, 3)=5
.
Offline
#204 2017-03-20 21:49:53
- alicson
- Member
- Registered: 2004-05-26
- Posts: 465
- Website
Re: etc_pagination: paginate everything
I didn’t mean human-behavior-wise, I meant the structure of the site allowing for calls to imaginary pages that can cause a problem. ;) Sounds like the answer is the “create a record for every encountered (even invalid) pg value”.
Ahh txp:etc_query can assign like txp:variable; no wonder.
I think it’s good to go now, again with much thanks :)
textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation
Offline
#205 2017-03-20 22:29:42
- etc
- Developer
- Registered: 2010-11-11
- Posts: 4,079
- Website
Re: etc_pagination: paginate everything
Yep, your site seems to work faster now. Have you cached “Category slates” and “Months menu” too? Good luck, and glad to help! :-)
Offline
#206 2017-09-03 17:54:19
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,453
Re: etc_pagination: paginate everything
Can someone please show me how I can bring these two elements to work? With section (or with category in an other case). All my experiments with the examples given in the help and in the forum gave no outputs.
I need only this basic pagination:
<txp:article_custom section="section-name" sort="LastMod desc" limit="12" form="form-name" />
<txp:etc_pagination range="0">
<p>Page {*} of {pages}</p>
</txp:etc_pagination>
Offline
#207 2017-09-03 20:20:53
- etc
- Developer
- Registered: 2010-11-11
- Posts: 4,079
- Website
Re: etc_pagination: paginate everything
GugUser wrote #306832:
Can someone please show me how I can bring these two elements to work? With section (or with category in an other case).
I guess you need to paginate <txp:article_custom />
list? Then you need to calculate the number of pages and offset:
<txp:article_custom section="section-name" sort="LastMod desc" limit="12" offset='<txp:etc_offset pgcounter="page" pageby="12" />' form="form-name" />
<txp:variable name="numPages" value='<txp:etc_numpages section="section-name" pageby="12" />' />
<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" range="0">
Page {*} of {pages}.
</txp:etc_pagination>
Adding page=3
(say) to url will land you on the 3rd page. Hope that helps.
Offline
#208 2017-09-03 22:20:18
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,453
Re: etc_pagination: paginate everything
This works, many thanks.
This means that all for the pagination relevant attributes from <txp:article />
, but unknown to <txp:article_custom />
, can be placed in offset=' '
, also pgonly
?
That’s great, thank you.
I was confused, amongst other things, by this example, where there is no variable
which transfers the data, and where pgonly="0"
(without being an attribute of <txp:article_custom />
) is outside the offset=' '
.
Offline
#209 2017-09-04 02:51:44
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,453
Re: etc_pagination: paginate everything
No, with pgonly
in <txp:article_custom />
, inside the offset=' '
, it can’t work. I made it with en empty form.
In this manner the <txp:article_custom />
that is only for pgonly
isn’t shown.
Offline
#210 2017-09-04 10:01:14
- etc
- Developer
- Registered: 2010-11-11
- Posts: 4,079
- Website
Re: etc_pagination: paginate everything
GugUser wrote #306839:
No, with
pgonly
in<txp:article_custom />
, inside theoffset=' '
, it can’t work.
FYI, in 4.7-dev <txp:article_custom section="some-section" pageby="12" pgonly />
returns the number of matching pages. We could also enhance its offset
attribute to treat non-numeric values as page number url parameter. So
<txp:article_custom section="some-section" limit="12" offset="page" />
would output the 3rd page of 12 articles (articles 25—36) if url query string contains page=3
.
Offline