Keyword

Pagination page titles or canonical link

  • Andy Connell
  • Andy Connell's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 9 months ago - 10 years 9 months ago #123937 by Andy Connell
Pagination page titles or canonical link was created by Andy Connell
Some of my category pages have many items/articles, so my pagination can sometimes be long.

I want to add a prefix Page 2, Page 3, Page 4 on the pages after the initial page, so that my page titles do not look like duplicates for SEO purposes

Please can anybody help me with adding in the prefix so title on page two looks like this Page 2 | My Page Title and incrementing for additional pages in the pagination sequence.

What code can I use and where best to add it?

Alternatively how can I create a canonical link back to page one for the inner pagination pages?

Thanks in advance,

Andy

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 9 months ago #123938 by Yiota
I would recommend you used the sh404sef extension which solves this issue with the duplicate pages.

Another solution, haven't tried it myself, is this
forum.joomla.org/viewtopic.php?f=544&t=454510&view=previous
along with SEF enabled of course.

Please Log in or Create an account to join the conversation.

  • Andy Connell
  • Andy Connell's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 9 months ago #123939 by Andy Connell
Replied by Andy Connell on topic Re: Pagination page titles or canonical link
Hi, thanks for your reply.
I do use SH404 SEF & it works pretty well for the most part.

My question/problem is for pages with pagination (i.e. page 2 of a list of articles), I want page to have a slightly different Title soa maybe prefix all pagination pages with P1 | , P2 |, P3 | , Etc

Please Log in or Create an account to join the conversation.

More
10 years 9 months ago #123940 by Lefteris
Replied by Lefteris on topic Re: Pagination page titles or canonical link
Hi. No currently i am afraid that you cannot do this.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Theodore Hildebrandt
  • Theodore Hildebrandt's Avatar
  • Offline
  • New Member
More
9 years 1 month ago #147979 by Theodore Hildebrandt
Replied by Theodore Hildebrandt on topic Pagination page titles or canonical link
This is super easy.

In the file /components/com_k2/views/itemlist/view.html.php

Find (Line 196):
// Set layout
				$this->setLayout('category');

				// Set title
				$title = $category->name;

Change it to:
// Set layout
				$this->setLayout('category');
				$titlesuffix = ' Page #' . (intval($limitstart/$limit)+1);
				// Set title
				$title = $category->name . $titlesuffix;

Change it to suit your preference for the text.

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago #153096 by ataman79
Replied by ataman79 on topic Pagination page titles or canonical link

Theodore Hildebrandt wrote: This is super easy.

In the file /components/com_k2/views/itemlist/view.html.php

Find (Line 196):

// Set layout
				$this->setLayout('category');

				// Set title
				$title = $category->name;

Change it to:
// Set layout
				$this->setLayout('category');
				$titlesuffix = ' Page #' . (intval($limitstart/$limit)+1);
				// Set title
				$title = $category->name . $titlesuffix;

Change it to suit your preference for the text.


Thnaks for the solution Theodore!
What about the tag pages with pagination ?
What files must be edited?

And one more question. Can all this be done in k2 templates, and not to hardcore k2 files?
Thanks in advance

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #153114 by Krikor Boghossian
Replied by Krikor Boghossian on topic Pagination page titles or canonical link
It can be done actually, but you need a bit different approach.
This function should be used docs.joomla.org/Customising_the_dynamic_page_title

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Theodore Hildebrandt
  • Theodore Hildebrandt's Avatar
  • Offline
  • New Member
More
5 years 5 months ago #172291 by Theodore Hildebrandt
Replied by Theodore Hildebrandt on topic Pagination page titles or canonical link
That would be wonderful if it actually worked. Unfortunately, it does not.

I tried everything suggested both here on your forum and on the Joomla forum before modifying the code in the view.html.php. Nothing worked, except the code I posted above.

I agree that a method that does not modify these types of files would be most preferable. Unfortunately no method like that suggested so far actually works.

Please Log in or Create an account to join the conversation.

More
5 years 5 months ago - 5 years 5 months ago #172298 by JoomlaWorks
Replied by JoomlaWorks on topic Pagination page titles or canonical link
This is actually an interesting feature to add in the itemlist views. To be fair, you don't really need to modify the actual view file, you can reset the document title in your template override, e.g. at the top of category.php (line 12, here github.com/getk2/k2/blob/master/components/com_k2/templates/default/category.php#L12) you can add:
$limitstart = JRequest::getInt('limitstart');
$limit = JRequest::getInt('limit');
$page = intval($limitstart/$limit) + 1;

$currentTitle = $this->params->get('page_title');

$document = JFactory::getDocument();
$document->setTitle($currentTitle.' - Page '.$page);

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Last edit: 5 years 5 months ago by JoomlaWorks. Reason: Updated "$params->get" with "$this->params->get"

Please Log in or Create an account to join the conversation.

  • Theodore Hildebrandt
  • Theodore Hildebrandt's Avatar
  • Offline
  • New Member
More
5 years 5 months ago #172302 by Theodore Hildebrandt
Replied by Theodore Hildebrandt on topic Pagination page titles or canonical link
Have you actually tried that to see the result of it?

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum