Navigation
Advertisement
Page titles load from flat file

If you are like me, The pages of your site include from another file for easy changing of the site. However this doesn't let you set a custom title and description for each page which stinks. This tutorial shows you how to have your cake and eat it to.
Now, You are going to go to your top.php (Or whatever you named it) and paste this PHP Code before anything else.

<?php $titles = @file("titles.txt");



$count_titles=count($titles);



$script_name_rev=strrev($_SERVER['PHP_SELF']);


$script_name_parse=explode('/',$script_name_rev);


$script_name=strrev($script_name_parse[0]);



$page_title=""; $page_description="";



for ($i=0;$i<$count_titles;$i++){


    if (strstr($titles[$i],"$script_name"."_title")){


        $page_title_parse=explode("=",$titles[$i]);


        $page_title=trim($page_title_parse[1]);        


    }


    if (strstr($titles[$i],"$script_name"."_description")){


        $page_description_parse=explode("=",$titles[$i]);


        $page_description=trim($page_description_parse[1]);        


    }    


}



?>

Now go down to your existing title's code and paste this over it:

<title><?php echo $page_title; ?></title>
 

And paste this over your existing description code:

<meta name="description" content="<?php echo $page_description; ?>">

Now you need to make a file titles.txt This keeps all the page's titles and descriptions in it.
index.php_title= Colinsmiley.net | Home index.php_description= My home page with news ----------------------------- about.php_title= Colinsmiley.net | About about.php_description= My about page -----------------------------
Just make a new one for each page you have. Thats it, upload and see if it works... If you can't get it to feel free to contact me and I will see if I can help.