Hi there, I want to know that how to control meta tags (Title, description, Keywords) of the dynamic web pages that are created in php. Any help will be appreciated. Best Regards KB
Simply use variables substitution as in other parts of the page. <title><?=$this_page_title?></title> content of the $this_page_title can come from your database by example.
how would you change the title and meta data depending on the name of the file? ie if it was index.php display certain information, if it was aboutus.php display other information, etc etc
I use like this: if ($_SERVER['REQUEST_URI']=="/index.html" || $_SERVER['REQUEST_URI']=="/" || strpos( $_SERVER['REQUEST_URI'],"news")) { $title = "onetitle"; }else{ $title = "othertitle"; } PHP: It checks whether displayed page is main or URL contains "news" and set appropriate value to $title variable
If you create a website dynamicly with php can't you not create dynamic meta tags for that website when you dynamicly created the webpage itself?
I think you should be more specific... what do you mean with "control" Maybe you should use mysql or just a simple include. Please tell us more details about your needs....
ok cool on my homepage (either / or index.php) i want a specific title and meta data to be displayed. when you click on a link to another page on the site, say products.php, the title and meta data must change to what i have made for products.php; then if you click on help the title and meta data must change again. all the title and meta data information must be in one file, say meta.php which is included in to all the pages on the site
Think I understand what you mean. I had such problem in the past. Though mine is not perfect, it does my job. I have sites over 40-50 pages with this model. if your page displayed is ie: mydomain.com/details.php?content=aboutus then your content is aboutus.htm, details.php reads(includes) the htm file and other function reads(includes) aboutus.txt which is the title,desc/keywords Long shot, but works for me. is this what you want ?
Sure, have a look.. in a file called root.php3 //content file $htm = ".htm"; $pid = "$detail$htm"; function show_detail($pid) { if (!preg_match("/http/", $pid)) { require($pid); } else { echo "NO no no..!!!"; die; } } //end //title file $txt = ".txt"; $title = "$detail$txt"; function show_title($title) { if (!preg_match("/http/", $title)) { require($title); } else { echo "NO no no..!!!"; die; } } //end PHP: and in details.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <? require("root.php3"); show_title("$title"); ............ ............. ........ show_detail("$pid"); ....... ....... </body> </html> PHP: the line if (!preg_match("/http/", $pid)) is needed cos, some bright kid might try to use your domain as his spamming base. if there is http match (yourdomain.com/contents.php?detail=http://spamdomain.com/aboutus.htm or even txt) in the requested file, it stops Try..