How to hide elements on pagination pages in MODX Revolution
I decided to note it for the future. Actually the question of hiding some elements, text or section on pagination pages - this is one of the basic points of technical optimization of the site.
Then search engines crawl your site, they must add the first page of pagination in the index. For this reason, the text should only be on it. If you show the text on all pages, the main page can be defined as a double, and "thrown" out of the index or lowered in ranking. We don't need that.
My question was how to get the page number from the URL parameters in MODX. You can write a snippet, but there must be faster options, right? There should be and there are.
So, since pagination is most often implemented via the pdoPage snippet of the pdoTools package, you can use the playshoder installed by this snippet:
[[+page:isgte=`2`:then=``:else=`
[[*content]]
`]]
If the page is greater than or equal to 2, it outputs nothing. Otherwise, it outputs content field, or whatever you want - you can put HTML layout there, and everything else.
Also an interesting variant - the same thing, but page
get not as placeholder from snippet, but as placeholder from GET parameters. It turns out that pdoTools adds a syntax for getting URL parameters - an interesting feature I didn't know about.
[[!#get.page]]
The syntax of the condition will be the same as in the first example.
For those who work with Fenom - output will also be via a condition with GET parameters. For example (most likely you can write just if with negation of the condition, but now there is no time to test it):
{if $.get['page']}
{else}
{$_modx->resource.content}
{/if}