News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Paginate titles

Started by Fabiolas, April 05, 2012, 08:45:27 PM

Previous topic - Next topic

Fabiolas

Anyway to paginate titles?

For example, i have one topic with 3 pages and i want this:

First Page: "Title of topic"
Second Page: "Title of topic - Page 2"
Third Page: "Title of topic - Page 3"

This is really important for better rankings in search engines because prevent duplicated titles.

Thanks!

Fabiolas

#1
Solution:

Quote from: http://www.brightcherry.co.uk/scribbles/smf-show-page-number-in-thread-title/Open the file index.template.php, it should be located in the theme folder of whichever theme you're using.

Search for the following 2 line:<title>', $context['page_title'], '</title>';

Replace it with:  if($context['page_info']['current_page'] > 1)
  {
    echo "<title>" . $context['page_title'] . " [Page " . $context['page_info']['current_page'] . "]</title>";
  }
  else
  {
    echo "<title>" . $context['page_title'] . "</title>";
  }


Save changes, upload the file.
It's as simple as that.

Lord only know why there's so much static noise over this issue.

If anyone tries this, please let me know how you get on.

BGH

#2
This doesn't work for me, as I have a different line for my index.template.php:


<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '', '
<title>', $context['page_title_html_safe'], '</title>';


I tried to delete this line, and add yours but it gives me an error.

I'd appreciate if anyone could me with this, thanks in advance!

Regards

Paracelsus

Quote from: BGH on April 07, 2012, 07:35:21 AM
This doesn't work for me, as I have a different line for my index.template.php:


<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '', '
<title>', $context['page_title_html_safe'], '</title>';


I tried to delete this line, and add yours but it gives me an error.

I'd appreciate if anyone could me with this, thanks in advance!

Regards


Try to change all 'page_title' ocurrences in the suggested solution with 'page_title_html_safe'.

Fabiolas

Quote from: BGH on April 07, 2012, 07:35:21 AM
This doesn't work for me, as I have a different line for my index.template.php:


<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '', '
<title>', $context['page_title_html_safe'], '</title>';


I tried to delete this line, and add yours but it gives me an error.

I'd appreciate if anyone could me with this, thanks in advance!

Regards


What error?

MrPhil

If this is your existing code:
<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '', '
<title>', $context['page_title_html_safe'], '</title>';


change it to
<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '', '
<title>', $context['page_title_html_safe'],
        ($context['page_info']['current_page'] > 1)? ' - Page ' . $context['page_info']['current_page']: '',
        '</title>';

Tomy Tran

Quote from: MrPhil on April 09, 2012, 05:57:18 PM
If this is your existing code:
<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '', '
<title>', $context['page_title_html_safe'], '</title>';


change it to
<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '', '
<title>', $context['page_title_html_safe'],
        ($context['page_info']['current_page'] > 1)? ' - Page ' . $context['page_info']['current_page']: '',
        '</title>';


Good solution.

BGH

Sorry for not answering with much details, but the solution provided by MrPhil worked out the box for me.

Thank you all! :)

Advertisement: