CrazyCrisUk
01-30-2012, 10:57 AM
I want to use a variable in the <title></title> to display the name of the article being shown on the page.
Each page uses an included header and footer file, and output buffering is being used.
So each page starts like this..
<?
$page_title = "Page Title";
include 'header.php';
include 'footer.php';
?>
...and header.php echos out the $page_title in the title tag.
However I want the $page_title varible to reflect the actual name of the article, which is set dynamically in the $article_title variable further down the page. Something like..
<?
$page_title = $article_title;
include 'header.php';
$article_title = $result['title'];
include 'footer.php';
?>
But of course due to the way I'm including the header this needs to be put before the variable is actually set causing the problem.
I already use output buffering, is there a way i can use this to help? This has to be quite a common problem I think...
Thanks in advance! This has been a problem to me for a while and I can't figure out the best way around it!!
Each page uses an included header and footer file, and output buffering is being used.
So each page starts like this..
<?
$page_title = "Page Title";
include 'header.php';
include 'footer.php';
?>
...and header.php echos out the $page_title in the title tag.
However I want the $page_title varible to reflect the actual name of the article, which is set dynamically in the $article_title variable further down the page. Something like..
<?
$page_title = $article_title;
include 'header.php';
$article_title = $result['title'];
include 'footer.php';
?>
But of course due to the way I'm including the header this needs to be put before the variable is actually set causing the problem.
I already use output buffering, is there a way i can use this to help? This has to be quite a common problem I think...
Thanks in advance! This has been a problem to me for a while and I can't figure out the best way around it!!