Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Robster - maaliskuu 07, 2014, 05:37:11 AP

Otsikko: Parent name in child board page title
Kirjoitti: Robster - maaliskuu 07, 2014, 05:37:11 AP
I've started using child boards on my forum, and noticed that only the name of the child board is in the HTML page title.

I would like to change it so that it matches the breadcrumb trail ie: <title>Site Name - Parent Name - Child Name</title>

What's the easiest/cleanest way to do this?
Otsikko: Re: Parent name in child board page title
Kirjoitti: margarett - maaliskuu 07, 2014, 05:42:27 AP
It needs some custom coding, I can try to peek later today.

I'm moving this to Coding ;)
Otsikko: Re: Parent name in child board page title
Kirjoitti: margarett - maaliskuu 07, 2014, 07:29:41 IP
So, here it goes.

Sources/MessageIndex.php
Find:
// 'Print' the header and board info.
$context['page_title'] = strip_tags($board_info['name']);

Replace with:
//A trick to show forum name + all board structure in window title :)
$w_title = $context['forum_name_html_safe'];
foreach ($context['linktree'] as $key => $value)
if (strpos($value['url'], 'index.php?board=') !== false)
$w_title .= ' - ' . $value['name'];
// 'Print' the header and board info.
$context['page_title'] = strip_tags($w_title);
Otsikko: Re: Parent name in child board page title
Kirjoitti: Robster - maaliskuu 12, 2014, 05:33:08 IP
Great thanks, will give this a try.