Web Design Blog

This is where we store some of our Web Development thoughts, tips and tricks, just because we like to share.

SMF- Show Page Number In Thread Title

My God, I’ve only just recently started playing around with SM Forums, and I can honestly say the documentation is God awful. At least, it’s terrible compared to WordPress. Also, it’s not coded that great- even applying the simpliest of features require plugins (“mods”, as the SMF community call them) and/or hacks.

Anyways, in this case, I wanted to show the page number of the thread in the page title to avoid duplicate title tags. I searched high and low for a few hours, and there is extremely tedious and ridiculous solutions floating around. Someone has even created a plugin (mod package) to apply this feature. To me, that seems a bit O.T.T. You shouldn’t need to install a mod to apply such a simple feature, right? Right. So, this is my solution…

How to show page number in the 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:

1
2
	// ]]></script>
	<title>', $context['page_title'], '</title>';

Replace it with:

1
2
3
4
5
6
7
8
9
  // ]]></script>';
  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.

16 Sep 2009 / 0 Comments / SMF- Simple Machines Forum / by Maruf

Leave a Reply

© 2012 BrightCherry :)