Log in

View Full Version : Thread title in header?


monstermunch
11-23-2009, 08:41 PM
Hi,

Does anyone know if its possible to show the "thread title" in the header template, for some reason I cant get it to display.

im using the $thread[title] to try and display it but it dosent seem to work, although it seems to work in the title and showthread pages?

Probably something simple im doing wrong.

thanks

kh99
11-23-2009, 09:42 PM
I think it's because the header template is processed before $thread[title] is set. I don't know if there's a "standard" trick to get around that. I guess if you really wanted to do it you could use a plugin to insert it somehow, using the showthread_complete hook.

navbar isn't done till the end so it could go near the navbar (but I guess it's already in the navbar :)).

monstermunch
11-24-2009, 07:22 AM
I think it's because the header template is processed before $thread[title] is set. I don't know if there's a "standard" trick to get around that. I guess if you really wanted to do it you could use a plugin to insert it somehow, using the showthread_complete hook.

navbar isn't done till the end so it could go near the navbar (but I guess it's already in the navbar :)).

I thought the same thing so decided to look at the showthread template and found $thread[title] is used in the <title></title> which is before the $header is called.. its odd as it seems to work before the $header, and in the $navbar but not in the $header template itself

kh99
11-24-2009, 08:15 AM
But looking at the code in showthread.php, $header is set at the beginning (in global.php) and the showthread template isn't used until the end (and $navbar is set near the end). So although the $header appears after the <title></title> in the template, it is already set before the template even begins.

Something could be inserted between <body> and $header, but of course that would put it at the very top of the page.

monstermunch
11-24-2009, 09:36 AM
But looking at the code in showthread.php, $header is set at the beginning (in global.php) and the showthread template isn't used until the end (and $navbar is set near the end). So although the $header appears after the <title></title> in the template, it is already set before the template even begins.

Something could be inserted between <body> and $header, but of course that would put it at the very top of the page.


I see, so its dosent look like it something that easy to do then

--------------- Added 1259076988 at 1259076988 ---------------

But looking at the code in showthread.php, $header is set at the beginning (in global.php) and the showthread template isn't used until the end (and $navbar is set near the end). So although the $header appears after the <title></title> in the template, it is already set before the template even begins.

Something could be inserted between <body> and $header, but of course that would put it at the very top of the page.

I just checked my showthread template and it goes in this order

<title></title>
$header
$navbar

it seems to work above the header, below the header, in the navbar, but not in the header , although I can get the forum topics to show in the header just no the thread/post title..

kh99
11-24-2009, 04:30 PM
I just checked my showthread template and it goes in this order

<title></title>
$header
$navbar


Right, but what "$header" does is take what is in the variable "$header" and insert it in the template at that point. So it doesn't matter where it is in the template, what matters is where $header is set in the .php file compared to where the template is eval'd. In showthread.php, $header is set (by evaluating the header template) at the top before $thread is set, so $thread[title] doesn't show up. The forum info must work because it's set before the header template is eval'd.

However - in checking out why the forum stuff works, I noticed that there's another thread variable that *is* set early, it's called "$threadinfo". So, if you use $threadinfo[title] it should work in the header. (But word wrapping and censoring has not been done at that point, so it may be different than what appears in later in the page, if you use either of those features).