healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 Well that worked with the title but now the formatting is just awful. The format is basically destroyed (see screenshot). Thanks for the catch on the center tag. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072445 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 I think where it's called matters very much for the formatting of the page. This isn't a very elegant solution but I'm thinking maybe I'm going to have to make a separate file for header information for each page and call it earlier separately? like home.head.php and just call that higher up. Is that the best i'm going to do? If that's the solution can you give me the statement to call home.head.php right before all of the header stuff? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072447 Share on other sites More sharing options...
Pikachu2000 Posted June 15, 2010 Share Posted June 15, 2010 The most efficient way to do this would be to create one header script, one footer script, and a script for each page's content. You would then, in each page's content script, define the title, keywords, and whatever other information you need to define before including the header or footer in the script. header.php <?php echo "<html><head><title>" . TITLE . "</title>"; echo "<meta name=\"keywords\" content=\"" . META . "\" /></head><body>"; ?> footer.php <?php echo "</body>"; echo "Copyright 2010 by me, blah, blah, blah"</body></html>; ?> body.php <?php define('TITLE', 'This is the page title.'); define('META', 'This is a meta tag'); include('header.php'); echo "This is the content of the page and other such stuff.<br />"; include('footer.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072453 Share on other sites More sharing options...
Bottyz Posted June 15, 2010 Share Posted June 15, 2010 totally agree with Pikachu. If you get stuck post the code from your index.php. It shouldn't screw up your layout at all. So that will be something in your current code. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072456 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 I am extremely lost and confused now. Where do I put all these files in \php\? is body.php really home.php biography.php etc.? This is way over my head. Is there somewhere I can read on how to do this? How and where do I call these things all into index.php? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072457 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 This is my whole current index.php <?php include "menu.inc.php"; function menu($_menu){ $str = ''; foreach($_menu as $url => $name){ $sel = ($_GET['page'] == $url ) ? ' id="selected" ' : ''; $str .= "<li ". $sel ."><a href=" . $url . " >" . $name . "</a>\n"; } echo $str; } $page = ( isset($_GET['pg']) ? $_GET['pg'] : ((isset($_GET['page']))? $_GET['page']:'home')); $file = basename($page).'.php'; $html_path = "php/"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo TITLE ?></title> <link rel="shortcut icon" href="img/favicon.ico" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content="en-us" /> <meta http-equiv="imagetoolbar" content="false" /> <meta name="author" content="Adroon Design | www.adroon.com" /> <meta name="copyright" content="Copyright (c) Health Basics LLC 2010" /> <meta name="description" content="Andrea Stevens is a clinical nutritionist specializing in consultations on digestive system dysfunction and children with neurological and developmental disorders as well as educational programs focusing on natural whole foods and wellness. Health Basics is an international distributor of natural health products, vitamins and supplements." /> <meta name="keywords" content="metabolic typing, body ecology, body ecology diet, digestive problems, digestive disorders, food sensitivities, dysbiosis, autism, asperberger syndrome, aspergers syndrome, asperger's syndrome, asperger, aspergers, asperger's, ASD, spectrum disorder, GI problems, GI disorders, gastrointestinal problems, gastrointestinal disorders, whole foods nutritionist, natural nutritionist, functional nutritionist, functional healthcare, organic foods, organic, holistic healing, holistic healthcare, digestive system disorders, candidiasis, candida, candida related problems, yeast related problems, yeast overgrowth, infant feeding, infant feeding problems, failure to thrive, children eating problems, children neurological problems, neurological problems, eating problems, seizures, behavior problems, learning problems, learning disabilities, learning disability, attention deficit disorder, ADD, attention deficit disorder, attention deficit hyperactivity disorder, ADHD, hyperactivity, hyperactivity disorder, DAN Protocol, leaky gut, crohns, crohn's, crohns disease, crohn's disease" /> <meta name="mssmarttagspreventparsing" content="true" /> <meta name="robots" content="index, follow, noarchive" /> <meta name="revisit-after" content="7 days" /> <meta name="google-site-verification" content="LLvcG6P8wvTcKL-RrhBEs7w0uMFrax06UrzaExDYvEY" /> <!--[if lt IE 7]> <script type="text/javascript" src="css/unitpngfix.js"></script> <![endif]--> </head> <body> <div id="wrapper"> <div id="header"> <div id="nav"> <a style="float:left" href="http://www.healthbasics.net/"><big><b>Health Basics™</b></big></a> <a href="<?php echo $_SERVER['PHP_SELF'].'?page=home'?>">Home</a> | <a href="<?php echo $_SERVER['PHP_SELF'].'?page=calendar'?>">Calendar</a> | <a href="http://shop.healthbasics.net/">Online Store</a> | <a href="./blog/">Blog</a> </div> <div id="bg"></div> </div> <div id="main-content"> <div id="left-column"> <div id="logo"><img src="img/logo.png" alt="" width="150" height="150" align="left" /><span class="logotxt1">Health</span> <span class="logotxt2">Basics</span><span class="logotxt3">TM</span><br /> <span style="margin-left:15px;">The website of Andrea Stevens, M.S., C.N.S., C.M.T.A. Clinical Nutritionist</span></div> <div class="box2"> <p><center>Using Whole Food Nutrition and Digestive System Health to Achieve your Health Goals Naturally</center></p> <ul style="margin-top:10px;"> <li>Consultations specializing in Digestive System Dysfunction and Children with Neurological and Developmental Disorders</li> <li>Educational Programs focusing on Natural, Whole Foods and Wellness</li> </ul> </div> <?php if (file_exists($html_path.$file)) include $html_path.$file; ?> </div> <div id="right-column"> <div id="main-image"><img src="img/andrea.jpg" height="240px" width="240px" alt="" /></div> <div class="sidebar"> <ul id="menu"> <? #include $html_path."menu.html"; menu($_menu); ?> <h3>Contacts</h3> <p> Health Basics LLC<br /> Toll Free: +1 877 HBNET 50<br /> Phone: +1 610 857 1399<br /> Fax: +1 815 550 1543<br /> Email: <a href="mailto:contact@healthbasics.net">contact@healthbasics.net</a><br /> Skype: health.basics</p> <h3>Subscribe</h3> <form method="post" action="http://healthbasics.net/blog/"> <input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>" /> <p> Your email: <br /> <input type="text" name="email" value="Enter email address..." size="20" onfocus="if (this.value == 'Enter email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter email address...';}" /> </p> <p> <input type="submit" name="subscribe" value="Subscribe" /> <input type="submit" name="unsubscribe" value="Unsubscribe" /> </p> </form> <p> <!-- comment out paypal <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="10802546"> <input type="image" src="img/paypal.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> --> </p> <p> </p> <p> <!-- comment out amazon <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=healbasi07-20&linkCode=ur2&camp=1789&creative=9325" target="_blank"><img src="img/amazon.gif" alt="" width="200px" height="26px"/></a> --> </p> </div> </div> <div id="footer"> <div id="footer_copy"> © 2010 <a href="http://healthbasics.net">Health Basics LLC</a>. All rights reserved. Developed by <a href="http://adroon.com">Adroon Design</a> <br/> <a href="http://shop.healthbasics.net/pages/disclaimer">Disclaimer</a> </div> <div id="footer_links"> <a href="http://www.facebook.com/pages/edit/picture.php?success=1&id=243139889898#/pages/Health-Basics/243139889898" target="_blank"><img src="img/facebook.png" alt="" /></a> <a href="http://twitter.com/HealthBasicsLLC" target="_blank"><img src="img/twitter.png" alt="" /></a> <a href="http://www.linkedin.com/profile?viewProfile=&key=61284894&authToken=Ic-E&authType=name" target="_blank"><img src="img/linkedin.png" alt="" /></a> </div> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072459 Share on other sites More sharing options...
TOA Posted June 15, 2010 Share Posted June 15, 2010 Now just define your TITLE constant in your other files. If you have contact.php, define TITLE to "Contact Page", if you have a info.php define TITLE to "INFO Page" inside that one. Then when the index includes 'filename'.php, the title will that's defined inside will come with it. Sessions might also be a reasonable solution Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072466 Share on other sites More sharing options...
Pikachu2000 Posted June 15, 2010 Share Posted June 15, 2010 That was meant to be just an illustrative example of the structure that would probably be best for you to use. It wasn't meant to be taken literally. Take a deep breath, and look at the logic of what is happening in the scripts. The body.php script first defines the constants that will be used in the header.php and (if necessary) footer.php scripts. Then it calls in the header.php script via the include('header.php") statement. Since the values of TITLE and META are defined before they are included for use in the script, they will have their values, and be usable. For all intents and purposes, an include() is no different than if you had pasted the included file directly in at that point. Next, the body.php script outputs the actual content of the page body. Finally, the footer.php script is included. In this manner, you can have one header.php script, one footer.php script, and a separate content script for each page, which will each use the same header and footer, via an include(), with whatever information you have defined in the content script. Does that make more sense? Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072469 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 Thanks guys. I'm almost there. Now here is what I have for index.php, it calls the header and the footer from separate files. All of the formatting is fine and perfect. I am just still confused about where exactly I put my TITLE, METADESC and METAKEYWORDS definitions and how I call up the body of each page? <?php include "menu.inc.php"; function menu($_menu){ $str = ''; foreach($_menu as $url => $name){ $sel = ($_GET['page'] == $url ) ? ' id="selected" ' : ''; $str .= "<li ". $sel ."><a href=" . $url . " >" . $name . "</a>\n"; } echo $str; } $page = ( isset($_GET['pg']) ? $_GET['pg'] : ((isset($_GET['page']))? $_GET['page']:'home')); $file = basename($page).'.php'; $html_path = "php/"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo TITLE ?></title> <link rel="shortcut icon" href="img/favicon.ico" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content="en-us" /> <meta http-equiv="imagetoolbar" content="false" /> <meta name="author" content="Adroon Design | www.adroon.com" /> <meta name="copyright" content="Copyright (c) Health Basics LLC 2010" /> <meta name="description" content="Andrea Stevens is a clinical nutritionist specializing in consultations on digestive system dysfunction and children with neurological and developmental disorders as well as educational programs focusing on natural whole foods and wellness. Health Basics is an international distributor of natural health products, vitamins and supplements." /> <meta name="keywords" content="metabolic typing, body ecology, body ecology diet, digestive problems, digestive disorders, food sensitivities, dysbiosis, autism, asperberger syndrome, aspergers syndrome, asperger's syndrome, asperger, aspergers, asperger's, ASD, spectrum disorder, GI problems, GI disorders, gastrointestinal problems, gastrointestinal disorders, whole foods nutritionist, natural nutritionist, functional nutritionist, functional healthcare, organic foods, organic, holistic healing, holistic healthcare, digestive system disorders, candidiasis, candida, candida related problems, yeast related problems, yeast overgrowth, infant feeding, infant feeding problems, failure to thrive, children eating problems, children neurological problems, neurological problems, eating problems, seizures, behavior problems, learning problems, learning disabilities, learning disability, attention deficit disorder, ADD, attention deficit disorder, attention deficit hyperactivity disorder, ADHD, hyperactivity, hyperactivity disorder, DAN Protocol, leaky gut, crohns, crohn's, crohns disease, crohn's disease" /> <meta name="mssmarttagspreventparsing" content="true" /> <meta name="robots" content="index, follow, noarchive" /> <meta name="revisit-after" content="7 days" /> <meta name="google-site-verification" content="LLvcG6P8wvTcKL-RrhBEs7w0uMFrax06UrzaExDYvEY" /> <!--[if lt IE 7]> <script type="text/javascript" src="css/unitpngfix.js"></script> <![endif]--> </head> <body> <?php include('./php/header.php') ?> <?php include('./php/footer.php'); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072471 Share on other sites More sharing options...
TOA Posted June 15, 2010 Share Posted June 15, 2010 Question: What's in your header.php file if you're defining your doctype and title in index? Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072473 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 Question: What's in your header.php file if you're defining your doctype and title in index? Going forward from getting header and footer to load from separate files I've only succeeded in completely destroying my website. What's in the header file is everything that loads the consist top part of the page. The menu, etc. etc. All the stuff that's the same on every page. This is what's in the header now <div id="wrapper"> <div id="header"> <div id="nav"> <a style="float:left" href="http://www.healthbasics.net/"><big><b>Health Basics™</b></big></a> <a href="<?php echo $_SERVER['PHP_SELF'].'?page=home'?>">Home</a> | <a href="<?php echo $_SERVER['PHP_SELF'].'?page=calendar'?>">Calendar</a> | <a href="http://shop.healthbasics.net/">Online Store</a> | <a href="./blog/">Blog</a> </div> <div id="bg"></div> </div> <div id="main-content"> <div id="left-column"> <div id="logo"><img src="img/logo.png" alt="" width="150" height="150" align="left" /><span class="logotxt1">Health</span> <span class="logotxt2">Basics</span><span class="logotxt3">TM</span><br /> <span style="margin-left:15px;">The website of Andrea Stevens, M.S., C.N.S., C.M.T.A. Clinical Nutritionist</span></div> <div class="box2"> <p><center>Using Whole Food Nutrition and Digestive System Health to Achieve your Health Goals Naturally</center></p> <ul style="margin-top:10px;"> <li>Consultations specializing in Digestive System Dysfunction and Children with Neurological and Developmental Disorders</li> <li>Educational Programs focusing on Natural, Whole Foods and Wellness</li> </ul> </div> <?php if (file_exists($html_path.$file)) include $html_path.$file; ?> </div> <div id="right-column"> <div id="main-image"><img src="img/andrea.jpg" height="240px" width="240px" alt="" /></div> <div class="sidebar"> <ul id="menu"> <? #include $html_path."menu.html"; menu($_menu); ?> <h3>Contacts</h3> <p> Health Basics LLC<br /> Toll Free: +1 877 HBNET 50<br /> Phone: +1 610 857 1399<br /> Fax: +1 815 550 1543<br /> Email: <a href="mailto:contact@healthbasics.net">contact@healthbasics.net</a><br /> Skype: health.basics</p> <h3>Subscribe</h3> <form method="post" action="http://healthbasics.net/blog/"> <input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>" /> <p> Your email: <br /> <input type="text" name="email" value="Enter email address..." size="20" onfocus="if (this.value == 'Enter email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter email address...';}" /> </p> <p> <input type="submit" name="subscribe" value="Subscribe" /> <input type="submit" name="unsubscribe" value="Unsubscribe" /> </p> </form> <p> <!-- comment out paypal <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="10802546"> <input type="image" src="img/paypal.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> --> </p> <p> </p> <p> <!-- comment out amazon <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=healbasi07-20&linkCode=ur2&camp=1789&creative=9325" target="_blank"><img src="img/amazon.gif" alt="" width="200px" height="26px"/></a> --> </p> </div> </div> I hope I can figure out how to get back to where i was. I've lost track because there are so many files now. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072477 Share on other sites More sharing options...
TOA Posted June 15, 2010 Share Posted June 15, 2010 I hope I can figure out how to get back to where i was. I've lost track because there are so many files now. Have faith. I've never been let down by this forum. Let me look at what you posted for a min Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072481 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 I guess among other problems (i.e. every time i try this it completely breaks my website) I can't see how I can get information that fundamental needs to be in my body page to load into the header which needs to be called before the body but if I do that it screws up all the formatting.... :-\ Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072484 Share on other sites More sharing options...
hcdarkmage Posted June 15, 2010 Share Posted June 15, 2010 Let's take this one step at a time. Going back over some of your code, I have seen some mistakes (i.e. missing end tags), but have faith. We are working on your problem. For your index.php, it should look similar to this: <?php include "menu.inc.php"; function menu($_menu){ $str = ''; foreach($_menu as $url => $name){ $sel = ($_GET['page'] == $url ) ? ' id="selected" ' : ''; $str .= "<li ". $sel ."><a href=" . $url . " >" . $name . "</a>\n"; } echo $str; } $page = ( isset($_GET['pg']) ? $_GET['pg'] : ((isset($_GET['page']))? $_GET['page']:'home')); $file = basename($page).'.php'; $html_path = "php/"; define('TITLE', 'This is the page title.'); include('./php/header.php'); ?> <div id="main-content"> <div id="left-column"> <div id="logo"> <img src="img/logo.png" alt="" width="150" height="150" align="left" /> <span class="logotxt1">Health</span> <span class="logotxt2">Basics</span> <span class="logotxt3">TM</span><br /><span style="margin-left:15px;">The website of Andrea Stevens, M.S., C.N.S., C.M.T.A. Clinical Nutritionist</span> </div> <div class="box2"> <p><center>Using Whole Food Nutrition and Digestive System Health to Achieve your Health Goals Naturally</center></p> <ul style="margin-top:10px;"> <li>Consultations specializing in Digestive System Dysfunction and Children with Neurological and Developmental Disorders</li> <li>Educational Programs focusing on Natural, Whole Foods and Wellness</li> </ul> </div> <?php if (file_exists($html_path.$file)) include $html_path.$file; ?> </div> <div id="right-column"> <div id="main-image"><img src="img/andrea.jpg" height="240px" width="240px" alt="" /></div> <div class="sidebar"> <ul id="menu"> <? #include $html_path."menu.html"; menu($_menu); ?> <h3>Contacts</h3> <p> Health Basics LLC<br /> Toll Free: +1 877 HBNET 50<br /> Phone: +1 610 857 1399<br /> Fax: +1 815 550 1543<br /> Email: <a href="mailto:contact@healthbasics.net">contact@healthbasics.net</a><br /> Skype: health.basics </p> <h3>Subscribe</h3> <form method="post" action="http://healthbasics.net/blog/"> <input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>" /> <p> Your email:<br /> <input type="text" name="email" value="Enter email address..." size="20" onfocus="if (this.value == 'Enter email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter email address...';}" /> </p> <p> <input type="submit" name="subscribe" value="Subscribe" /> <input type="submit" name="unsubscribe" value="Unsubscribe" /> </p> </form> <p> <!-- comment out paypal <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="10802546"> <input type="image" src="img/paypal.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> --> </p> <p> </p> <p> <!-- comment out amazon <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=healbasi07-20&linkCode=ur2&camp=1789&creative=9325" target="_blank"><img src="img/amazon.gif" alt="" width="200px" height="26px"/></a> --> </p> </div> </div> </div> <?php include('./php/footer.php'); ?> header.php will look something like: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo TITLE ?></title> <link rel="shortcut icon" href="img/favicon.ico" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content="en-us" /> <meta http-equiv="imagetoolbar" content="false" /> <meta name="author" content="Adroon Design | www.adroon.com" /> <meta name="copyright" content="Copyright (c) Health Basics LLC 2010" /> <meta name="description" content="Andrea Stevens is a clinical nutritionist specializing in consultations on digestive system dysfunction and children with neurological and developmental disorders as well as educational programs focusing on natural whole foods and wellness. Health Basics is an international distributor of natural health products, vitamins and supplements." /> <meta name="keywords" content="metabolic typing, body ecology, body ecology diet, digestive problems, digestive disorders, food sensitivities, dysbiosis, autism, asperberger syndrome, aspergers syndrome, asperger's syndrome, asperger, aspergers, asperger's, ASD, spectrum disorder, GI problems, GI disorders, gastrointestinal problems, gastrointestinal disorders, whole foods nutritionist, natural nutritionist, functional nutritionist, functional healthcare, organic foods, organic, holistic healing, holistic healthcare, digestive system disorders, candidiasis, candida, candida related problems, yeast related problems, yeast overgrowth, infant feeding, infant feeding problems, failure to thrive, children eating problems, children neurological problems, neurological problems, eating problems, seizures, behavior problems, learning problems, learning disabilities, learning disability, attention deficit disorder, ADD, attention deficit disorder, attention deficit hyperactivity disorder, ADHD, hyperactivity, hyperactivity disorder, DAN Protocol, leaky gut, crohns, crohn's, crohns disease, crohn's disease" /> <meta name="mssmarttagspreventparsing" content="true" /> <meta name="robots" content="index, follow, noarchive" /> <meta name="revisit-after" content="7 days" /> <meta name="google-site-verification" content="LLvcG6P8wvTcKL-RrhBEs7w0uMFrax06UrzaExDYvEY" /> <!--[if lt IE 7]> <script type="text/javascript" src="css/unitpngfix.js"></script> <![endif]--> </head> <body> <div id="wrapper"> <div id="header"> <div id="nav"> <a style="float:left" href="http://www.healthbasics.net/"><big><b>Health Basics™</b></big></a> <a href="<?php echo $_SERVER['PHP_SELF'].'?page=home'?>">Home</a> | <a href="<?php echo $_SERVER['PHP_SELF'].'?page=calendar'?>">Calendar</a> | <a href="http://shop.healthbasics.net/">Online Store</a> | <a href="./blog/">Blog</a> </div> <div id="bg"></div> </div> And footer.php something like: <div id="footer"> <div id="footer_copy"> © 2010 <a href="http://healthbasics.net">Health Basics LLC</a>. All rights reserved. Developed by <a href="http://adroon.com">Adroon Design</a><br/> <a href="http://shop.healthbasics.net/pages/disclaimer">Disclaimer</a> </div> <div id="footer_links"> <a href="http://www.facebook.com/pages/edit/picture.php?success=1&id=243139889898#/pages/Health-Basics/243139889898" target="_blank"><img src="img/facebook.png" alt="" /></a> <a href="http://twitter.com/HealthBasicsLLC" target="_blank"><img src="img/twitter.png" alt="" /></a> <a href="http://www.linkedin.com/profile?viewProfile=&key=61284894&authToken=Ic-E&authType=name" target="_blank"><img src="img/linkedin.png" alt="" /></a> </div> </div> </div> </body> </html> This should help you see how it works with the separation of the files. Your constants on all pages are header.php and footer.php. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072494 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 Ok I can modify everything to look like that and test it but what I still don't now how to do is setup home.php, contact.php, client_comments.php, etc. How to call them appropriately into index and how it is that I'm going to just get the dynamic keywords, meta description and title I originally set out for... Can anyone tell me what those missing pieces are? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072497 Share on other sites More sharing options...
TOA Posted June 15, 2010 Share Posted June 15, 2010 Let's take this one step at a time. Going back over some of your code, I have seen some mistakes (i.e. missing end tags), but have faith. We are working on your problem. For your index.php, it should look similar to this: <?php include "menu.inc.php"; function menu($_menu){ $str = ''; foreach($_menu as $url => $name){ $sel = ($_GET['page'] == $url ) ? ' id="selected" ' : ''; $str .= "<li ". $sel ."><a href=" . $url . " >" . $name . "</a>\n"; } echo $str; } $page = ( isset($_GET['pg']) ? $_GET['pg'] : ((isset($_GET['page']))? $_GET['page']:'home')); $file = basename($page).'.php'; $html_path = "php/"; define('TITLE', 'This is the page title.'); include('./php/header.php'); ?> <div id="main-content"> <div id="left-column"> <div id="logo"> <img src="img/logo.png" alt="" width="150" height="150" align="left" /> <span class="logotxt1">Health</span> <span class="logotxt2">Basics</span> <span class="logotxt3">TM</span><br /><span style="margin-left:15px;">The website of Andrea Stevens, M.S., C.N.S., C.M.T.A. Clinical Nutritionist</span> </div> <div class="box2"> <p><center>Using Whole Food Nutrition and Digestive System Health to Achieve your Health Goals Naturally</center></p> <ul style="margin-top:10px;"> <li>Consultations specializing in Digestive System Dysfunction and Children with Neurological and Developmental Disorders</li> <li>Educational Programs focusing on Natural, Whole Foods and Wellness</li> </ul> </div> <?php if (file_exists($html_path.$file)) include $html_path.$file; ?> </div> <div id="right-column"> <div id="main-image"><img src="img/andrea.jpg" height="240px" width="240px" alt="" /></div> <div class="sidebar"> <ul id="menu"> <? #include $html_path."menu.html"; menu($_menu); ?> <h3>Contacts</h3> <p> Health Basics LLC<br /> Toll Free: +1 877 HBNET 50<br /> Phone: +1 610 857 1399<br /> Fax: +1 815 550 1543<br /> Email: <a href="mailto:contact@healthbasics.net">contact@healthbasics.net</a><br /> Skype: health.basics </p> <h3>Subscribe</h3> <form method="post" action="http://healthbasics.net/blog/"> <input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>" /> <p> Your email:<br /> <input type="text" name="email" value="Enter email address..." size="20" onfocus="if (this.value == 'Enter email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter email address...';}" /> </p> <p> <input type="submit" name="subscribe" value="Subscribe" /> <input type="submit" name="unsubscribe" value="Unsubscribe" /> </p> </form> <p> <!-- comment out paypal <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="10802546"> <input type="image" src="img/paypal.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> --> </p> <p> </p> <p> <!-- comment out amazon <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=healbasi07-20&linkCode=ur2&camp=1789&creative=9325" target="_blank"><img src="img/amazon.gif" alt="" width="200px" height="26px"/></a> --> </p> </div> </div> </div> <?php include('./php/footer.php'); ?> header.php will look something like: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo TITLE ?></title> <link rel="shortcut icon" href="img/favicon.ico" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content="en-us" /> <meta http-equiv="imagetoolbar" content="false" /> <meta name="author" content="Adroon Design | www.adroon.com" /> <meta name="copyright" content="Copyright (c) Health Basics LLC 2010" /> <meta name="description" content="Andrea Stevens is a clinical nutritionist specializing in consultations on digestive system dysfunction and children with neurological and developmental disorders as well as educational programs focusing on natural whole foods and wellness. Health Basics is an international distributor of natural health products, vitamins and supplements." /> <meta name="keywords" content="metabolic typing, body ecology, body ecology diet, digestive problems, digestive disorders, food sensitivities, dysbiosis, autism, asperberger syndrome, aspergers syndrome, asperger's syndrome, asperger, aspergers, asperger's, ASD, spectrum disorder, GI problems, GI disorders, gastrointestinal problems, gastrointestinal disorders, whole foods nutritionist, natural nutritionist, functional nutritionist, functional healthcare, organic foods, organic, holistic healing, holistic healthcare, digestive system disorders, candidiasis, candida, candida related problems, yeast related problems, yeast overgrowth, infant feeding, infant feeding problems, failure to thrive, children eating problems, children neurological problems, neurological problems, eating problems, seizures, behavior problems, learning problems, learning disabilities, learning disability, attention deficit disorder, ADD, attention deficit disorder, attention deficit hyperactivity disorder, ADHD, hyperactivity, hyperactivity disorder, DAN Protocol, leaky gut, crohns, crohn's, crohns disease, crohn's disease" /> <meta name="mssmarttagspreventparsing" content="true" /> <meta name="robots" content="index, follow, noarchive" /> <meta name="revisit-after" content="7 days" /> <meta name="google-site-verification" content="LLvcG6P8wvTcKL-RrhBEs7w0uMFrax06UrzaExDYvEY" /> <!--[if lt IE 7]> <script type="text/javascript" src="css/unitpngfix.js"></script> <![endif]--> </head> <body> <div id="wrapper"> <div id="header"> <div id="nav"> <a style="float:left" href="http://www.healthbasics.net/"><big><b>Health Basics™</b></big></a> <a href="<?php echo $_SERVER['PHP_SELF'].'?page=home'?>">Home</a> | <a href="<?php echo $_SERVER['PHP_SELF'].'?page=calendar'?>">Calendar</a> | <a href="http://shop.healthbasics.net/">Online Store</a> | <a href="./blog/">Blog</a> </div> <div id="bg"></div> </div> And footer.php something like: <div id="footer"> <div id="footer_copy"> © 2010 <a href="http://healthbasics.net">Health Basics LLC</a>. All rights reserved. Developed by <a href="http://adroon.com">Adroon Design</a><br/> <a href="http://shop.healthbasics.net/pages/disclaimer">Disclaimer</a> </div> <div id="footer_links"> <a href="http://www.facebook.com/pages/edit/picture.php?success=1&id=243139889898#/pages/Health-Basics/243139889898" target="_blank"><img src="img/facebook.png" alt="" /></a> <a href="http://twitter.com/HealthBasicsLLC" target="_blank"><img src="img/twitter.png" alt="" /></a> <a href="http://www.linkedin.com/profile?viewProfile=&key=61284894&authToken=Ic-E&authType=name" target="_blank"><img src="img/linkedin.png" alt="" /></a> </div> </div> </div> </body> </html> This should help you see how it works with the separation of the files. Your constants on all pages are header.php and footer.php. That's what I was going to advise. I think your structure was all wrong. Ok I can modify everything to look like that and test it but what I still don't now how to do is setup home.php, contact.php, client_comments.php, etc. How to call them appropriately into index and how it is that I'm going to just get the dynamic keywords, meta description and title I originally set out for... Can anyone tell me what those missing pieces are? Thanks. And as for that, I think you're misunderstanding that too. index.php is (usually) just another name for home. It can be used to draw in other pages (like a place holder) though. Which is it that you would like to do? Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072502 Share on other sites More sharing options...
hcdarkmage Posted June 15, 2010 Share Posted June 15, 2010 I can see how this is confusing. On those pages that you are asking about (home.php, contact.php, etc.) do they have the same initial setup? if so then you just repeat the code for each page so that you get the proper stuff. For instance home.php: <?php include "menu.inc.php"; function menu($_menu){ $str = ''; foreach($_menu as $url => $name){ $sel = ($_GET['page'] == $url ) ? ' id="selected" ' : ''; $str .= "<li ". $sel ."><a href=" . $url . " >" . $name . "</a>\n"; } echo $str; } $page = ( isset($_GET['pg']) ? $_GET['pg'] : ((isset($_GET['page']))? $_GET['page']:'home')); $file = basename($page).'.php'; $html_path = "php/"; define('TITLE', 'This is the page title.'); // <--- Change the page title here include('./php/header.php'); ?> <div id="main-content"> //insert home.php contents here. </div> <?php include('./php/footer.php'); ?> The same would go for any page that you have. As for the meta tags, you can do the same thing as the title, like what was posted at the begining of this post. Just define it under the title definition. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072504 Share on other sites More sharing options...
hcdarkmage Posted June 15, 2010 Share Posted June 15, 2010 Before you do any of the suggested above, could you please post the code from home.php or one of the other pages that are called. I think I may have found a problem with what has been suggested so far. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072513 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 Ok I followed all those instructions but now I have no titles at all and the formatting is completely trashed. see: http://www.healthbasics.net Perhaps I need to specificly point out that home.php and index.php are the same thing. home.php is the default content to fill up the page otherwise it would be blank. It also happens to like to the Philosophy & Focus button on the right. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072516 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 Before you do any of the suggested above, could you please post the code from home.php or one of the other pages that are called. I think I may have found a problem with what has been suggested so far. I missed this message and I already changed it to the suggested.... I think this is what it WAS but it's hard for me to keep track of so many files, I htink I've about tripled the number of files on my site since this morning. <?php include "menu.inc.php"; function menu($_menu){ $str = ''; foreach($_menu as $url => $name){ $sel = ($_GET['page'] == $url ) ? ' id="selected" ' : ''; $str .= "<li ". $sel ."><a href=" . $url . " >" . $name . "</a>\n"; } echo $str; } $page = ( isset($_GET['pg']) ? $_GET['pg'] : ((isset($_GET['page']))? $_GET['page']:'home')); $file = basename($page).'.php'; $html_path = "php/"; define('TITLE', 'Health Basics | The website of Andrea Stevens, M.S., C.N.S., C.M.T.A. Clinical Nutritionist'); include('./php/header.php'); ?> <div id="main-content"> <h2>Philosophy & Focus</h2> <p>My primary goal is to assist clients in achieving the highest degree of health possible for themselves and their families. Drawing upon up-to-date scientific findings as well as forgotten but highly valuable knowledge - which includes old-fashioned methods of food preparation - I enjoy helping others to use natural ways to support their health and avoid illness and disease. Prescription medication, with its highly undesirable side effects, should not be the first or primary method of addressing ill health.</p> <p><br /> The human body is wonderfully designed with countless mechanisms to stay healthy and balanced. If we can provide the body with all the natural raw materials (an abundance of nutrients, pure water, clean air, and love and intimacy among them) that it needs, as well as support the elimination of waste material and toxins, the body can heal many conditions and increase its levels of health, energy and vitality.</p> <p><br /> <div class="box"> <center><b><i><p>Essential Nutrients in... Waste out!</p> <p>This is a model that all living organisms follow in order to thrive and flourish.</p></b></i></center> </div> <p><br /> <p>Before turning to over-the-counter and prescription medications - which primarily suppress symptoms instead of address the underlying causes of dysfunction - understanding, and then supporting, the natural processes of the body will often result in a marked decrease or elimination of those symptoms. Symptoms are nature's way of calling our attention to problems in the body. Perhaps we are meant to listen to those signals and then correct the habits in our lifestyle that contribute to the underlying dysfunction (which then results in specific symptoms). These habits usually involve failing to provide the body with enough of the raw materials it needs, and hampering its detoxification, or waste removal, pathways.</p> <p><br /> <p>The answer to our health problems doesn't lie in treating (suppressing) symptoms, but in addressing the causes - which are generally some combination of nutritional deficiencies and waste buildup within the body.</p> <p><br /> <p>Two major concepts govern my approach. The first is that of biochemical individuality, which states that no two people are exactly alike and, therefore, no one dietary program is best for everyone... the Metabolic Typing philosophy addresses this. Secondly, I believe - as most physicians did prior to the mid 20th century - that overall health is directly dependent upon the health of the gastrointestinal or digestive tract... the Body Ecology approach addresses this.</p> <p><br /> <p>I hold a firm belief in the inherent power, wisdom, and uniqueness in each of us. Eating natural, unaltered whole foods grown or raised in a healthy and socially responsible manner, along with proper digestive system-processing of those foods, are key to achieving optimal health, energy and vitality.</p> <p><br /> <div class="box"> <center><b><i><p>We need to Understand the <b>BASICS</b> of Body Functioning and the <B>BASICS</B> of Health-Supporting Food in order to Achieve BASIC Good Health. </p></b></i></center> </div> <p><br /> <p>Specific conditions which can be successfully treated through Whole Food Nutrition and Optimal Digestive System Functioning include:</p> <p><br /> <p>Overt Digestive Problems</p> <ul> <li>Infant and Child Feeding Problems</li> <li>Reflux/GERD</li> <li>Food Sensitivities, Allergies, Intolerances</li> <li>Heartburn/Indigestion</li> <li>Bloating/Gas</li> <li>Constipation</li> <li>Diarrhea / Loose Bowel Movements</li> <li>Irritable Bowel Syndrome (IBS)</li> </ul> <p><br /> <p>Systemic Problems Related to an Underlying Unhealthy Digestive System</p> <ul> <li>Candidiasis</li> <li>Autism Spectrum Disorder</li> <li>Attention Deficit Disorder (ADD), Attention Deficit Hypactivity Disorder (ADHD) and other Behavior and Learning Problems</li> <li>Epilepsy and Seizures</li> <li>Autoimmune Conditions like Rheumatoid Arthritis, Lupus, Multiple Sclerosis</li> <li>Chronic Fatigue</li> <li>Fibromyalgia</li> <li>"Mysterious Medical Maladies" - conditions unable to be successfully diagnosed or treated within the traditional healthcare system</li> </ul> <p><br /> <p>Prevention of Health Problems and Disease</p> <ul> <li>Pregnancy Preparation</li> <li>Pregnancy</li> <li>Graceful Aging</li> <li>Optimal Levels of Energy, Vitality and Health</li> </ul> <!-- START Google Analytics --> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-12299340-1"); pageTracker._setDomainName(".healthbasics.net"); pageTracker._trackPageview(); } catch(err) {}</script> <!-- Google Analytics END --> <!-- Start of StatCounter Code --> <script type="text/javascript"> var sc_project=5441595; var sc_invisible=1; var sc_partition=54; var sc_click_stat=1; var sc_security="a84f73c6"; </script> <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a title="web analytics" class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c.statcounter.com/5441595/0/a84f73c6/1/" alt="web analytics" /></a></div></noscript> <!-- End of StatCounter Code --> </div> <?php include('./php/footer.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072517 Share on other sites More sharing options...
KevinM1 Posted June 15, 2010 Share Posted June 15, 2010 Ok I followed all those instructions but now I have no titles at all and the formatting is completely trashed. see: http://www.healthbasics.net Perhaps I need to specificly point out that home.php and index.php are the same thing. home.php is the default content to fill up the page otherwise it would be blank. It also happens to like to the Philosophy & Focus button on the right. Take a look at your site's source code (the HTML, not the PHP). You're missing your header and footer code, so there's no styling, or even <html> tags. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072519 Share on other sites More sharing options...
hcdarkmage Posted June 15, 2010 Share Posted June 15, 2010 I guess it's a good thing that I copied your index.php code before suggesting any changes: <?php include "menu.inc.php"; function menu($_menu){ $str = ''; foreach($_menu as $url => $name){ $sel = ($_GET['page'] == $url ) ? ' id="selected" ' : ''; $str .= "<li ". $sel ."><a href=" . $url . " >" . $name . "</a>\n"; } echo $str; } $page = ( isset($_GET['pg']) ? $_GET['pg'] : ((isset($_GET['page']))? $_GET['page']:'home')); $file = basename($page).'.php'; $html_path = "php/"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo TITLE ?></title> <link rel="shortcut icon" href="img/favicon.ico" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content="en-us" /> <meta http-equiv="imagetoolbar" content="false" /> <meta name="author" content="Adroon Design | www.adroon.com" /> <meta name="copyright" content="Copyright (c) Health Basics LLC 2010" /> <meta name="description" content="Andrea Stevens is a clinical nutritionist specializing in consultations on digestive system dysfunction and children with neurological and developmental disorders as well as educational programs focusing on natural whole foods and wellness. Health Basics is an international distributor of natural health products, vitamins and supplements." /> <meta name="keywords" content="metabolic typing, body ecology, body ecology diet, digestive problems, digestive disorders, food sensitivities, dysbiosis, autism, asperberger syndrome, aspergers syndrome, asperger's syndrome, asperger, aspergers, asperger's, ASD, spectrum disorder, GI problems, GI disorders, gastrointestinal problems, gastrointestinal disorders, whole foods nutritionist, natural nutritionist, functional nutritionist, functional healthcare, organic foods, organic, holistic healing, holistic healthcare, digestive system disorders, candidiasis, candida, candida related problems, yeast related problems, yeast overgrowth, infant feeding, infant feeding problems, failure to thrive, children eating problems, children neurological problems, neurological problems, eating problems, seizures, behavior problems, learning problems, learning disabilities, learning disability, attention deficit disorder, ADD, attention deficit disorder, attention deficit hyperactivity disorder, ADHD, hyperactivity, hyperactivity disorder, DAN Protocol, leaky gut, crohns, crohn's, crohns disease, crohn's disease" /> <meta name="mssmarttagspreventparsing" content="true" /> <meta name="robots" content="index, follow, noarchive" /> <meta name="revisit-after" content="7 days" /> <meta name="google-site-verification" content="LLvcG6P8wvTcKL-RrhBEs7w0uMFrax06UrzaExDYvEY" /> <!--[if lt IE 7]> <script type="text/javascript" src="css/unitpngfix.js"></script> <![endif]--> </head> <body> <div id="wrapper"> <div id="header"> <div id="nav"> <a style="float:left" href="http://www.healthbasics.net/"><big><b>Health Basics™</b></big></a> <a href="<?php echo $_SERVER['PHP_SELF'].'?page=home'?>">Home</a> | <a href="<?php echo $_SERVER['PHP_SELF'].'?page=calendar'?>">Calendar</a> | <a href="http://shop.healthbasics.net/">Online Store</a> | <a href="./blog/">Blog</a> </div> <div id="bg"></div> </div> <div id="main-content"> <div id="left-column"> <div id="logo"> <img src="img/logo.png" alt="" width="150" height="150" align="left" /> <span class="logotxt1">Health</span> <span class="logotxt2">Basics</span> <span class="logotxt3">TM</span><br /><span style="margin-left:15px;">The website of Andrea Stevens, M.S., C.N.S., C.M.T.A. Clinical Nutritionist</span> </div> <div class="box2"> <p><center>Using Whole Food Nutrition and Digestive System Health to Achieve your Health Goals Naturally</center></p> <ul style="margin-top:10px;"> <li>Consultations specializing in Digestive System Dysfunction and Children with Neurological and Developmental Disorders</li> <li>Educational Programs focusing on Natural, Whole Foods and Wellness</li> </ul> </div> <?php if (file_exists($html_path.$file)) include $html_path.$file; ?> </div> <div id="right-column"> <div id="main-image"><img src="img/andrea.jpg" height="240px" width="240px" alt="" /></div> <div class="sidebar"> <ul id="menu"> <? #include $html_path."menu.html"; menu($_menu); ?> <h3>Contacts</h3> <p> Health Basics LLC<br /> Toll Free: +1 877 HBNET 50<br /> Phone: +1 610 857 1399<br /> Fax: +1 815 550 1543<br /> Email: <a href="mailto:contact@healthbasics.net">contact@healthbasics.net</a><br /> Skype: health.basics </p> <h3>Subscribe</h3> <form method="post" action="http://healthbasics.net/blog/"> <input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>" /> <p> Your email:<br /> <input type="text" name="email" value="Enter email address..." size="20" onfocus="if (this.value == 'Enter email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter email address...';}" /> </p> <p> <input type="submit" name="subscribe" value="Subscribe" /> <input type="submit" name="unsubscribe" value="Unsubscribe" /> </p> </form> <p> <!-- comment out paypal <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="10802546"> <input type="image" src="img/paypal.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> --> </p> <p> </p> <p> <!-- comment out amazon <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=healbasi07-20&linkCode=ur2&camp=1789&creative=9325" target="_blank"><img src="img/amazon.gif" alt="" width="200px" height="26px"/></a> --> </p> </div> </div> </div> <div id="footer"> <div id="footer_copy"> © 2010 <a href="http://healthbasics.net">Health Basics LLC</a>. All rights reserved. Developed by <a href="http://adroon.com">Adroon Design</a><br/> <a href="http://shop.healthbasics.net/pages/disclaimer">Disclaimer</a> </div> <div id="footer_links"> <a href="http://www.facebook.com/pages/edit/picture.php?success=1&id=243139889898#/pages/Health-Basics/243139889898" target="_blank"><img src="img/facebook.png" alt="" /></a> <a href="http://twitter.com/HealthBasicsLLC" target="_blank"><img src="img/twitter.png" alt="" /></a> <a href="http://www.linkedin.com/profile?viewProfile=&key=61284894&authToken=Ic-E&authType=name" target="_blank"><img src="img/linkedin.png" alt="" /></a> </div> </div> </div> </body> </html> I noticed one line in the code that should stand out (if one was looking properly ). <?php if (file_exists($html_path.$file)) include $html_path.$file; ?> This code incorporates the separate pages into the index.php page. That and function menu($_menu){ $str = ''; foreach($_menu as $url => $name){ $sel = ($_GET['page'] == $url ) ? ' id="selected" ' : ''; $str .= "<li ". $sel ."><a href=" . $url . " >" . $name . "</a>\n"; } echo $str; } Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072525 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 Your last post kind of trailed off there. I don't know what i'm supposed to do. Here is what I have now: index.php <?php include "menu.inc.php"; function menu($_menu){ $str = ''; foreach($_menu as $url => $name){ $sel = ($_GET['page'] == $url ) ? ' id="selected" ' : ''; $str .= "<li ". $sel ."><a href=" . $url . " >" . $name . "</a>\n"; } echo $str; } $page = ( isset($_GET['pg']) ? $_GET['pg'] : ((isset($_GET['page']))? $_GET['page']:'home')); $file = basename($page).'.php'; $html_path = "php/"; define('TITLE', "Health Basics | The Website Of Andrea Stevens, M.S., C.N.S., C.M.T.A. Clinical Nutritionist"); define('METATAGDESC', "Andrea Stevens is a clinical nutritionist specializing in consultations on digestive system dysfunction and children with neurological and developmental disorders as well as educational programs focusing on natural whole foods and wellness. Health Basics is an international distributor of natural health products, vitamins and supplements."); define('METAKEYWORDS', "metabolic typing, body ecology, body ecology diet, digestive problems, digestive disorders, food sensitivities, dysbiosis, autism, asperberger syndrome, aspergers syndrome, asperger's syndrome, asperger, aspergers, asperger's, ASD, spectrum disorder, GI problems, GI disorders, gastrointestinal problems, gastrointestinal disorders, whole foods nutritionist, natural nutritionist, functional nutritionist, functional healthcare, organic foods, organic, holistic healing, holistic healthcare, digestive system disorders, candidiasis, candida, candida related problems, yeast related problems, yeast overgrowth, infant feeding, infant feeding problems, failure to thrive, children eating problems, children neurological problems, neurological problems, eating problems, seizures, behavior problems, learning problems, learning disabilities, learning disability, attention deficit disorder, ADD, attention deficit disorder, attention deficit hyperactivity disorder, ADHD, hyperactivity, hyperactivity disorder, DAN Protocol, leaky gut, crohns, crohn's, crohns disease, crohn's disease"); include('./php/header.php'); ?> <div id="main-content"> <div id="left-column"> <div id="logo"> <img src="img/logo.png" alt="" width="150" height="150" align="left" /> <span class="logotxt1">Health</span> <span class="logotxt2">Basics</span> <span class="logotxt3">TM</span><br /><span style="margin-left:15px;">The website of Andrea Stevens, M.S., C.N.S., C.M.T.A. Clinical Nutritionist</span> </div> <div class="box2"> <p><center>Using Whole Food Nutrition and Digestive System Health to Achieve your Health Goals Naturally</center></p> <ul style="margin-top:10px;"> <li>Consultations specializing in Digestive System Dysfunction and Children with Neurological and Developmental Disorders</li> <li>Educational Programs focusing on Natural, Whole Foods and Wellness</li> </ul> </div> <?php if (file_exists($html_path.$file)) include $html_path.$file; ?> </div> <div id="right-column"> <div id="main-image"><img src="img/andrea.jpg" height="240px" width="240px" alt="" /></div> <div class="sidebar"> <ul id="menu"> <? #include $html_path."menu.html"; menu($_menu); ?> <h3>Contacts</h3> <p> Health Basics LLC<br /> Toll Free: +1 877 HBNET 50<br /> Phone: +1 610 857 1399<br /> Fax: +1 815 550 1543<br /> Email: <a href="mailto:contact@healthbasics.net">contact@healthbasics.net</a><br /> Skype: health.basics </p> <h3>Subscribe</h3> <form method="post" action="http://healthbasics.net/blog/"> <input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>" /> <p> Your email:<br /> <input type="text" name="email" value="Enter email address..." size="20" onfocus="if (this.value == 'Enter email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter email address...';}" /> </p> <p> <input type="submit" name="subscribe" value="Subscribe" /> <input type="submit" name="unsubscribe" value="Unsubscribe" /> </p> </form> <p> <!-- comment out paypal <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="10802546"> <input type="image" src="img/paypal.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> --> </p> <p> </p> <p> <!-- comment out amazon <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=healbasi07-20&linkCode=ur2&camp=1789&creative=9325" target="_blank"><img src="img/amazon.gif" alt="" width="200px" height="26px"/></a> --> </p> </div> </div> </div> <?php include('./php/footer.php'); ?> home.php <?php define(TITLE, "Health Basics | The Website Of Andrea Stevens, M.S., C.N.S., C.M.T.A. Clinical Nutritionist"); define(METATAGDESC, "Andrea Stevens is a clinical nutritionist specializing in consultations on digestive system dysfunction and children with neurological and developmental disorders as well as educational programs focusing on natural whole foods and wellness. Health Basics is an international distributor of natural health products, vitamins and supplements."); define(METAKEYWORDS, "metabolic typing, body ecology, body ecology diet, digestive problems, digestive disorders, food sensitivities, dysbiosis, autism, asperberger syndrome, aspergers syndrome, asperger's syndrome, asperger, aspergers, asperger's, ASD, spectrum disorder, GI problems, GI disorders, gastrointestinal problems, gastrointestinal disorders, whole foods nutritionist, natural nutritionist, functional nutritionist, functional healthcare, organic foods, organic, holistic healing, holistic healthcare, digestive system disorders, candidiasis, candida, candida related problems, yeast related problems, yeast overgrowth, infant feeding, infant feeding problems, failure to thrive, children eating problems, children neurological problems, neurological problems, eating problems, seizures, behavior problems, learning problems, learning disabilities, learning disability, attention deficit disorder, ADD, attention deficit disorder, attention deficit hyperactivity disorder, ADHD, hyperactivity, hyperactivity disorder, DAN Protocol, leaky gut, crohns, crohn's, crohns disease, crohn's disease"); ?> <h2>Philosophy & Focus</h2> <p>My primary goal is to assist clients in achieving the highest degree of health possible for themselves and their families. Drawing upon up-to-date scientific findings as well as forgotten but highly valuable knowledge - which includes old-fashioned methods of food preparation - I enjoy helping others to use natural ways to support their health and avoid illness and disease. Prescription medication, with its highly undesirable side effects, should not be the first or primary method of addressing ill health.</p> <p><br /> The human body is wonderfully designed with countless mechanisms to stay healthy and balanced. If we can provide the body with all the natural raw materials (an abundance of nutrients, pure water, clean air, and love and intimacy among them) that it needs, as well as support the elimination of waste material and toxins, the body can heal many conditions and increase its levels of health, energy and vitality.</p> <p><br /> <div class="box"> <center><b><i><p>Essential Nutrients in... Waste out!</p> <p>This is a model that all living organisms follow in order to thrive and flourish.</p></b></i></center> </div> <p><br /> <p>Before turning to over-the-counter and prescription medications - which primarily suppress symptoms instead of address the underlying causes of dysfunction - understanding, and then supporting, the natural processes of the body will often result in a marked decrease or elimination of those symptoms. Symptoms are nature's way of calling our attention to problems in the body. Perhaps we are meant to listen to those signals and then correct the habits in our lifestyle that contribute to the underlying dysfunction (which then results in specific symptoms). These habits usually involve failing to provide the body with enough of the raw materials it needs, and hampering its detoxification, or waste removal, pathways.</p> <p><br /> <p>The answer to our health problems doesn't lie in treating (suppressing) symptoms, but in addressing the causes - which are generally some combination of nutritional deficiencies and waste buildup within the body.</p> <p><br /> <p>Two major concepts govern my approach. The first is that of biochemical individuality, which states that no two people are exactly alike and, therefore, no one dietary program is best for everyone... the Metabolic Typing philosophy addresses this. Secondly, I believe - as most physicians did prior to the mid 20th century - that overall health is directly dependent upon the health of the gastrointestinal or digestive tract... the Body Ecology approach addresses this.</p> <p><br /> <p>I hold a firm belief in the inherent power, wisdom, and uniqueness in each of us. Eating natural, unaltered whole foods grown or raised in a healthy and socially responsible manner, along with proper digestive system-processing of those foods, are key to achieving optimal health, energy and vitality.</p> <p><br /> <div class="box"> <center><b><i><p>We need to Understand the <b>BASICS</b> of Body Functioning and the <B>BASICS</B> of Health-Supporting Food in order to Achieve BASIC Good Health. </p></b></i></center> </div> <p><br /> <p>Specific conditions which can be successfully treated through Whole Food Nutrition and Optimal Digestive System Functioning include:</p> <p><br /> <p>Overt Digestive Problems</p> <ul> <li>Infant and Child Feeding Problems</li> <li>Reflux/GERD</li> <li>Food Sensitivities, Allergies, Intolerances</li> <li>Heartburn/Indigestion</li> <li>Bloating/Gas</li> <li>Constipation</li> <li>Diarrhea / Loose Bowel Movements</li> <li>Irritable Bowel Syndrome (IBS)</li> </ul> <p><br /> <p>Systemic Problems Related to an Underlying Unhealthy Digestive System</p> <ul> <li>Candidiasis</li> <li>Autism Spectrum Disorder</li> <li>Attention Deficit Disorder (ADD), Attention Deficit Hypactivity Disorder (ADHD) and other Behavior and Learning Problems</li> <li>Epilepsy and Seizures</li> <li>Autoimmune Conditions like Rheumatoid Arthritis, Lupus, Multiple Sclerosis</li> <li>Chronic Fatigue</li> <li>Fibromyalgia</li> <li>"Mysterious Medical Maladies" - conditions unable to be successfully diagnosed or treated within the traditional healthcare system</li> </ul> <p><br /> <p>Prevention of Health Problems and Disease</p> <ul> <li>Pregnancy Preparation</li> <li>Pregnancy</li> <li>Graceful Aging</li> <li>Optimal Levels of Energy, Vitality and Health</li> </ul> header.php <HTML> <HEAD> <title><?php echo TITLE ?></title> <link rel="shortcut icon" href="img/favicon.ico" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content="en-us" /> <meta http-equiv="imagetoolbar" content="false" /> <meta name="author" content="Adroon Design | www.adroon.com" /> <meta name="copyright" content="Copyright (c) Health Basics LLC 2010" /> <meta name="description" content="Andrea Stevens is a clinical nutritionist specializing in consultations on digestive system dysfunction and children with neurological and developmental disorders as well as educational programs focusing on natural whole foods and wellness. Health Basics is an international distributor of natural health products, vitamins and supplements." /> <meta name="keywords" content="metabolic typing, body ecology, body ecology diet, digestive problems, digestive disorders, food sensitivities, dysbiosis, autism, asperberger syndrome, aspergers syndrome, asperger's syndrome, asperger, aspergers, asperger's, ASD, spectrum disorder, GI problems, GI disorders, gastrointestinal problems, gastrointestinal disorders, whole foods nutritionist, natural nutritionist, functional nutritionist, functional healthcare, organic foods, organic, holistic healing, holistic healthcare, digestive system disorders, candidiasis, candida, candida related problems, yeast related problems, yeast overgrowth, infant feeding, infant feeding problems, failure to thrive, children eating problems, children neurological problems, neurological problems, eating problems, seizures, behavior problems, learning problems, learning disabilities, learning disability, attention deficit disorder, ADD, attention deficit disorder, attention deficit hyperactivity disorder, ADHD, hyperactivity, hyperactivity disorder, DAN Protocol, leaky gut, crohns, crohn's, crohns disease, crohn's disease" /> <meta name="mssmarttagspreventparsing" content="true" /> <meta name="robots" content="index, follow, noarchive" /> <meta name="revisit-after" content="7 days" /> <meta name="google-site-verification" content="LLvcG6P8wvTcKL-RrhBEs7w0uMFrax06UrzaExDYvEY" /> <!--[if lt IE 7]> <script type="text/javascript" src="css/unitpngfix.js"></script> <![endif]--> </HEAD> <BODY> <div id="wrapper"> <div id="header"> <div id="nav"> <a style="float:left" href="http://www.healthbasics.net/"><big><b>Health Basics™</b></big></a> <a href="<?php echo $_SERVER['PHP_SELF'].'?page=home'?>">Home</a> | <a href="<?php echo $_SERVER['PHP_SELF'].'?page=calendar'?>">Calendar</a> | <a href="http://shop.healthbasics.net/">Online Store</a> | <a href="./blog/">Blog</a> </div> <div id="bg"></div> </div> <div id="main-content"> <div id="left-column"> <div id="logo"><img src="img/logo.png" alt="" width="150" height="150" align="left" /><span class="logotxt1">Health</span> <span class="logotxt2">Basics</span><span class="logotxt3">TM</span><br /> <span style="margin-left:15px;">The website of Andrea Stevens, M.S., C.N.S., C.M.T.A. Clinical Nutritionist</span></div> <div class="box2"> <p><center>Using Whole Food Nutrition and Digestive System Health to Achieve your Health Goals Naturally</center></p> <ul style="margin-top:10px;"> <li>Consultations specializing in Digestive System Dysfunction and Children with Neurological and Developmental Disorders</li> <li>Educational Programs focusing on Natural, Whole Foods and Wellness</li> </ul> </div> <?php if (file_exists($html_path.$file)) include $html_path.$file; ?> </div> <div id="right-column"> <div id="main-image"><img src="img/andrea.jpg" height="240px" width="240px" alt="" /></div> <div class="sidebar"> <ul id="menu"> <? #include $html_path."menu.html"; menu($_menu); ?> <h3>Contacts</h3> <p> Health Basics LLC<br /> Toll Free: +1 877 HBNET 50<br /> Phone: +1 610 857 1399<br /> Fax: +1 815 550 1543<br /> Email: <a href="mailto:contact@healthbasics.net">contact@healthbasics.net</a><br /> Skype: health.basics</p> <h3>Subscribe</h3> <form method="post" action="http://healthbasics.net/blog/"> <input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>" /> <p> Your email: <br /> <input type="text" name="email" value="Enter email address..." size="20" onfocus="if (this.value == 'Enter email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter email address...';}" /> </p> <p> <input type="submit" name="subscribe" value="Subscribe" /> <input type="submit" name="unsubscribe" value="Unsubscribe" /> </p> </form> <p> <!-- comment out paypal <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="10802546"> <input type="image" src="img/paypal.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> --> </p> <p> </p> <p> <!-- comment out amazon <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=healbasi07-20&linkCode=ur2&camp=1789&creative=9325" target="_blank"><img src="img/amazon.gif" alt="" width="200px" height="26px"/></a> --> </p> </div> </div> footer.php <div id="footer"> <div id="footer_copy"> © 2010 <a href="http://healthbasics.net">Health Basics LLC</a>. All rights reserved. Developed by <a href="http://adroon.com">Adroon Design</a> <br/> <a href="http://shop.healthbasics.net/pages/disclaimer">Disclaimer</a> </div> <div id="footer_links"> <a href="http://www.facebook.com/pages/edit/picture.php?success=1&id=243139889898#/pages/Health-Basics/243139889898" target="_blank"><img src="img/facebook.png" alt="" /></a> <a href="http://twitter.com/HealthBasicsLLC" target="_blank"><img src="img/twitter.png" alt="" /></a> <a href="http://www.linkedin.com/profile?viewProfile=&key=61284894&authToken=Ic-E&authType=name" target="_blank"><img src="img/linkedin.png" alt="" /></a> </div> </div> <!-- START Google Analytics --> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-12299340-1"); pageTracker._setDomainName(".healthbasics.net"); pageTracker._trackPageview(); } catch(err) {}</script> <!-- Google Analytics END --> <!-- Start of StatCounter Code --> <script type="text/javascript"> var sc_project=5441595; var sc_invisible=1; var sc_partition=54; var sc_click_stat=1; var sc_security="a84f73c6"; </script> <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a title="web analytics" class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c.statcounter.com/5441595/0/a84f73c6/1/" alt="web analytics" /></a></div></noscript> <!-- End of StatCounter Code --> </div> </BODY> </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072534 Share on other sites More sharing options...
healthbasics Posted June 15, 2010 Author Share Posted June 15, 2010 seems to be getting closer but everything repeats twice and the formatting is still awful. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072540 Share on other sites More sharing options...
hcdarkmage Posted June 15, 2010 Share Posted June 15, 2010 When we started to give you advice on how to make your title and metatags dynamic, we didn't have all the facts (or code for that matter) and we tried to help you with what we had. Now we have just screwed up your site. You are doubling code when you shouldn't have to. I re-posted the original index.php code that you gave us earlier and noticed a few things that would make it hard for dynamic metas and stuff with the header.php and footer.php. Apparently, your index.php takes care of both of those for all the pages. Recopy the original code, and reset your site back to what it was. It looks like a different approach will be needed for getting the dynamic title and metatags. Quote Link to comment https://forums.phpfreaks.com/topic/204842-how-can-i-add-dynamic-titles-and-dynamic-meta-descriptions-to-my-pages/page/2/#findComment-1072542 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.