Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: Rohan_ on March 29, 2011, 01:33:42 AM

Title: Page Number in Titles
Post by: Rohan_ on March 29, 2011, 01:33:42 AM
Hello,

Currently when we browse different pages of any board or any topic the title in browser is still the same as original..

is it possible to add page 2, page 3 in the titles which appears on browsers title (no changes in url) ?

for example

currently if there is a board Jokes and it have 30 pages. and we are on any page the title is same all the time. but I want if i am on page 5 the title of the page should be this

Jokes - Page 5

not only Jokes on all pages... is it possible ?? Please help
Title: Re: Page Number in Titles
Post by: Illori on March 29, 2011, 05:57:03 AM
sounds like you may want to look into one of the url rewrite mods, although some of them have been known to cause issues.
Title: Re: Page Number in Titles
Post by: Rohan_ on March 29, 2011, 05:59:15 AM
i am using pretty urls :( does it cause any issues ?
Title: Re: Page Number in Titles
Post by: Illori on March 29, 2011, 06:00:54 AM
many people have reported things not working correctly since installing pretty urls, so yes it does cause issues and has little to no benefit.
Title: Re: Page Number in Titles
Post by: Kays on March 29, 2011, 07:07:35 AM
Hey, try this. It should work with pretty urls.

In Sources Subs, look for:


return $pageindex;


and add before it:


global $context;
$context['page_number'] = $start / $num_per_page + 1;


Then in Index.template.php of your theme look for:


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


And replace it with:


<title>', $context['page_title'], isset($context['page_number']) ? ' [Page ' . $context['page_number'] . ']' :'', '</title>';


It's not too language freindly, so translate "Page" if your forum is not in English

Title: Re: Page Number in Titles
Post by: Rohan_ on March 29, 2011, 08:11:33 AM
hello,

yes it worked.. but need some changes...

I don't want that to be displayed on page 1... page 1 should be only board's name

when the page is displayed like Board [Page 2]

i want a dash before that page thing and don't want those brackets so it will be like this

Board - Page 2

please help :)
Title: Re: Page Number in Titles
Post by: Kays on March 29, 2011, 08:29:35 AM
In Index.template.php revert the code back to how it was. Now right at the top of that function, look for:


// Show right to left and the character set for ease of translating.


And add before it:


if (isset($context['page_number']))
if ($context['page_number'] != 1)
$context['page_title'] .= ' - Page ' . $context['page_number'];


One thing I forgot to mention is that this will show like that for everywhere that a page index is created.
Title: Re: Page Number in Titles
Post by: Rohan_ on March 29, 2011, 08:38:53 AM
Done... Working great now..

can you clear me what does this actually mean ?

"this will show like that for everywhere that a page index is created"

I am little confused. by that you mean everywhere in boards, topics etc. etc. ?? well that's not a problem I wanted it like that :)

Thank you so much for helping and solving this :)
Title: Re: Page Number in Titles
Post by: Kays on March 29, 2011, 08:47:14 AM
Quote
I am little confused. by that you mean everywhere in boards, topics etc. etc. ?? well that's not a problem I wanted it like that :)

Cool, since that's how it will work. Member list, PMs and anywhere else that Pages 1 [2] etc is shown. :)