- Posts: 54
COMMUNITY FORUM
Pagination page titles or canonical link
- Andy Connell
-
Topic Author
- Offline
- Senior Member
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
-
- Visitor
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
-
Topic Author
- Offline
- Senior Member
- Posts: 54
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.
- Lefteris
-
- Offline
- Moderator
- Posts: 8743
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
-
- Offline
- New Member
- Posts: 4
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.
- ataman79
-
- Offline
- New Member
- Posts: 18
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
-
- Offline
- Platinum Member
- Posts: 15920
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
-
- Offline
- New Member
- Posts: 4
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.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
$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 :)
Please Log in or Create an account to join the conversation.
- Theodore Hildebrandt
-
- Offline
- New Member
- Posts: 4
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Fotis / 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
-
- Offline
- New Member
- Posts: 4
$limit = JRequest::getInt('limit');
"limit" is not passed as a request variable, since it depends on the number of leading items, primary items, secondary items and link items on a given page according to the configuration of that specific category page. So, it can't come directly from the component configuration, and it isn't passed as a request variable.
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.