A
A
Artyom2016-12-19 16:00:36
Yii
Artyom, 2016-12-19 16:00:36

How to check page parameter in Yii and show text based on its value?

The site has a category in which there are 1000 posts
On one page 20pcs
It turns out 50 pages
Text is added at the bottom of the category, and it is duplicated on all 50 pages, which is clearly duplicate content
I need code / help in order to do this, that is, show text only on the first category page
Yii 1.1.17

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Timofeev, 2016-12-19
@ixley

You clearly do not understand that there is content duplication, but if necessary, then this:
if everything is implemented correctly, then pagination is done through the ActiveDataProvider, which means you can do this:
in Yii2:

$current = $dataProvider->pagination->page;
if($current == 0){
echo $someMyTextData;
}

Documents on the topic:
www.yiiframework.com/doc-2.0/yii-data-activedatapr...
www.yiiframework.com/doc-2.0/yii-data-pagination.html
in Yii1:
$current = $dataProvider->pagination->currentPage;
if($current == 0){
echo $someMyTextData;
}

Documents on the topic:
www.yiiframework.com/doc/api/1.1/CDataProvider
www.yiiframework.com/doc/api/1.1/CPagination
PS: I would not suffer from nonsense, but make semantic markup for pagination:
schema.org/pagination
Google and Yandex eat it perfectly, and I would think about the canonical url again. In my opinion, the search engine does not need 50 pages with products. He needs 1 and many pages of the product itself.

I
Ilya Karavaev, 2016-12-19
@Quieteroks

Can you look towards DataProvider'ov? They do it all themselves, the only question is to change the design of each line.

I
Igor Karachentsev, 2016-12-19
@kucheriavij

either ajax pagination or canonical

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question