Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » How?
  3. » ?pg=

#1 2021-07-21 16:38:14

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,724
Website GitHub Twitter

?pg=

Is there a way to automatically detect the complete list of paginated urls in article_lists?

I’m trying to add those urls in the sitemap.


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Online

#2 2021-07-21 19:54:29

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,172
Website

Re: ?pg=

I guess this is going to be a factor of the total number of articles and the limit / pageby value you have in your txp:article(_custom) tag.

I know this isn’t the answer you are looking for, but Phil does exactly the opposite in the default theme. This part of the template code sets index and follow for the first page only. All other ?pg=x pages are set to noindex but also to follow so that the individual article pages linked to on those pages are found and indexed.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2021-07-21 20:17:11

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,371
Website GitHub Mastodon

Re: ?pg=

colak wrote #331074:

Is there a way to automatically detect the complete list of paginated urls in article_lists?

I’m trying to add those urls in the sitemap.

<txp:pages total />

I am not sure exactly what you need but my Complex Pagination code might help.

Offline

#4 2021-07-21 20:33:20

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,172
Website

Re: ?pg=

michaelkpate wrote #331078:

<txp:pages total />...

I am not sure exactly what you need but my Complex Pagination code might help.

Nice! As you say, one would need to iterate over the page url from 1 to total to create the individual page urls, which, in essence, is what a pagination series does.


TXP Builders – finely-crafted code, design and txp

Offline

#5 2021-07-22 03:52:46

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,724
Website GitHub Twitter

Re: ?pg=

Hi Michael,
and thanks for your code which admittedly it was the first thing I had a look at. What I am looking for is to produce the results below where all pages from 2 (as ?pg=1 is the same as /blog/) to the last whatever that may be.

<url><loc><txp:site_url />blog/?pg=2</loc></url>
<url><loc><txp:site_url />blog/?pg=3</loc></url>
<url><loc><txp:site_url />blog/?pg=4</loc></url>
...
<url><loc><txp:site_url />blog/?pg=last</loc></url>

I’m sure that there is an easy method for this and I just can’t see it.


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Online

#6 2021-07-22 07:40:01

Myusername
Member
Registered: 2019-12-12
Posts: 141

Re: ?pg=

If you are using a form with the txp:article tag, you can use txp:older. For example:

<txp:article pageby="10" pgonly />
<txp:variable name="counter" value="1" />

<txp:older total link="0">
	<txp:variable name="counter" value='<txp:evaluate query=''<txp:variable name="counter" /> + 1'' />' />
	<loc>pg=<txp:variable name="counter"/></loc>
</txp:older>

Result:

<loc>pg=2</loc>
<loc>pg=3</loc>
<loc>pg=4</loc>
<loc>pg=5</loc>
...

Last edited by Myusername (2021-07-22 07:42:16)

Offline

#7 2021-07-22 10:07:39

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,724
Website GitHub Twitter

Re: ?pg=

That is indeed a good idea!

The problem is that I have a section for the sitemap and the article tag does not recognise the section for which I need the ?pg=# urls. :(


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Online

#8 2021-07-22 11:33:59

etc
Developer
Registered: 2010-11-11
Posts: 4,515
Website GitHub

Re: ?pg=

colak wrote #331084:

The problem is that I have a section for the sitemap and the article tag does not recognise the section for which I need the ?pg=# urls. :(

In the latest txp <txp:article_custom /> can paginate too:

<txp:section_list>
<txp:page_url context="s" s='<txp:section />'>
<txp:pages total='<txp:article_custom section pgonly limit="2" />' />
<txp:pages total shift link="" break="loc">
<txp:yield item="url" />
</txp:pages>
</txp:page_url>
</txp:section_list>

Offline

#9 2021-07-22 15:21:25

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,724
Website GitHub Twitter

Re: ?pg=

Yummy… I’ll test it!


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Online

#10 2021-07-22 15:34:48

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,724
Website GitHub Twitter

Re: ?pg=

colak wrote #331086:

Yummy… I’ll test it!

I did. But it didn’t work.

The adapted code.

<txp:section_list>
<txp:page_url context="s" s="blog">
<txp:pages total='<txp:article_custom section="blog" pgonly limit="2" />' />
<txp:pages total shift link="" break="">
<url><loc><txp:yield item="url" /></loc></url>
</txp:pages>
</txp:page_url>
</txp:section_list>

the result:

<url><loc>https://www.domain.tld/sitemap/</loc></url>
<url><loc>https://www.domain.tld/sitemap/?pg=2</loc></url>
<url><loc>https://www.domain.tld/sitemap/?pg=3</loc></url>
...

ps. The result is the same when I delete context="s"


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Online

#11 2021-07-22 15:53:45

etc
Developer
Registered: 2010-11-11
Posts: 4,515
Website GitHub

Re: ?pg=

It works on the release demo. What is your txp version and context you use it: a page, an article?

Offline

#12 2021-07-22 17:10:20

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,724
Website GitHub Twitter

Re: ?pg=

Hi Oleg,

I use it in a page that is called from a section called sitemap and the latest vanilla release.


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Online

  1. Index
  2. » How?
  3. » ?pg=

Board footer

Powered by FluxBB