{"id":120,"date":"2009-07-19T07:00:38","date_gmt":"2009-07-19T11:00:38","guid":{"rendered":"http:\/\/awgentry.com\/blog\/?p=120"},"modified":"2009-07-19T07:00:38","modified_gmt":"2009-07-19T11:00:38","slug":"easy-menus-with-php-part-1","status":"publish","type":"post","link":"http:\/\/awgentry.com\/weblog\/easy-menus-with-php-part-1\/","title":{"rendered":"Easy Menus with PHP, Part 1"},"content":{"rendered":"<p>When I was first starting out in <a class=\"zem_slink\" title=\"Web design\" rel=\"wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/Web_design\">Web design<\/a>, I quickly learned that <strong>updating your site&#8217;s menus can become a major chore<\/strong> rather quickly. Since I liked to <a href=\"http:\/\/en.wikipedia.org\/wiki\/Hard_code\">hard-code<\/a> everything, I only knew a couple main options, neither of which were great:<\/p>\n<ol>\n<li><strong>Update every page manually:<\/strong> This works out for a while, but when you get a dozen or more pages, it starts to break down. Besides the fact that it&#8217;s time-consuming, you&#8217;re prone to errors, which can lead to dead links or orphaned pages. There&#8217;s gotta&#8217; be a better way&#8230;<\/li>\n<li><strong>Use <a href=\"http:\/\/en.wikipedia.org\/wiki\/HTML_element#Frames\">frames<\/a>:<\/strong><em> <\/em>Though this technique looked promising to begin with, it has many drawbacks:\n<ul>\n<li><em>You can&#8217;t <a class=\"zem_slink\" title=\"Bookmark (web)\" rel=\"wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/Bookmark_%28web%29\">bookmark<\/a> a page inside a frame.<\/em> The only page a user can bookmark, is the main homepage &#8212; the first framed page they come to. That means that if you&#8217;re studying the green-crested striped Moldavian iguana at the <em>Iguanapedia <\/em>website, and the page is inside a frame, you&#8217;ll be stuck with adding the main page to your favorites. Then you have to drill down to the inner page every time you arrive. No fun.<\/li>\n<li><em><a class=\"zem_slink\" title=\"Web search engine\" rel=\"wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/Web_search_engine\">Search engines<\/a> and others can&#8217;t read frames properly.<\/em> Here&#8217;s what a <a href=\"http:\/\/www.google.com\/support\/webmasters\/bin\/answer.py?hl=en&amp;answer=34445\">Google helpfile on frames<\/a> says:<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<blockquote>\n<p style=\"padding-left: 60px;\">Google supports frames and iframes to the extent that it can. Frames can cause problems for search engines because they don&#8217;t correspond to the conceptual model of the web. In this model, one page displays only one URL. Pages that use frames or iframes display several <a class=\"zem_slink\" title=\"Uniform Resource Locator\" rel=\"wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/Uniform_Resource_Locator\">URLs<\/a> (one for each frame) within a single page&#8230;<\/p>\n<p style=\"padding-left: 60px;\">[You may use] the &#8220;NoFrames&#8221; tag to provide alternate content. If you [don&#8217;t,] &#8230; then you&#8217;ll exclude both search engines and individuals who&#8217;ve disabled [or can&#8217;t use] frames on their browsers.<\/p>\n<\/blockquote>\n<p style=\"padding-left: 60px;\">In other words, frames seem cool, but search engines and frames-disabled browsers don&#8217;t like them. You&#8217;ll get partial support at best.<strong> <\/strong>If you take the time to make alternative content for them, you&#8217;re basically recreating your site &#8212; canceling out the time savings you wanted the frames to give you in the first place!<\/p>\n<p><strong>Easy Menus with PHP Includes<br \/>\n<\/strong>What&#8217;s a Web-coder to do? Lo and behold, the answer comes from <a href=\"http:\/\/php.net\/\">PHP programming<\/a>, and <strong><a href=\"http:\/\/us3.php.net\/include\/\" target=\"_blank\">PHP includes<\/a><\/strong> specifically.\u00a0<em><\/em>Now you can do one of three things:<\/p>\n<ul>\n<li>\n<div class=\"zemanta-img zemanta-action-dragged\">\n<div style=\"width: 150px\" class=\"wp-caption alignright\"><a href=\"http:\/\/www.flickr.com\/photos\/27403767@N00\/2218075860\"><img loading=\"lazy\" decoding=\"async\" class=\" \" title=\"PHP Elephant\" src=\"http:\/\/farm3.static.flickr.com\/2009\/2218075860_b78fd33f83_m.jpg\" alt=\"PHP Elephant\" width=\"144\" height=\"103\" \/><\/a><p class=\"wp-caption-text\">Image by Laughing Squid via Flickr<\/p><\/div>\n<\/div>\n<p>For you <a class=\"zem_slink\" title=\"Do it yourself\" rel=\"wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/Do_it_yourself\">DIY<\/a> types, go <a href=\"http:\/\/us3.php.net\/include\/\">check out the PHP.net description here<\/a>. Just plug in the PHP inside your <a class=\"zem_slink\" title=\"HTML\" rel=\"wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/HTML\">HTML<\/a> code.<\/li>\n<li>If you&#8217;re a managerial type who doesn&#8217;t want to get his hands dirty with all this, forward this post to your resident Webmaster. (<a href=\"http:\/\/awgentry.com\/blog\/?p=8\">You do have one<\/a>, right?)<\/li>\n<li>If you want a bit more hand-holding, <strong>come back tomorrow for a tutorial<\/strong>. See you soon!<\/li>\n<\/ul>\n<h6 class=\"zemanta-related-title\">Related articles by Zemanta<\/h6>\n<ul class=\"zemanta-article-ul\">\n<li class=\"zemanta-article-ul-li\"><a href=\"http:\/\/www.rchurt.com\/blogging-101-terms-you-must-know\">Blogging 101 &#8211; Terms You Must Know<\/a> (rchurt.com)<\/li>\n<li class=\"zemanta-article-ul-li\"><a href=\"http:\/\/www.brighthub.com\/internet\/web-development\/articles\/62614.aspx\">How to Open a PHP File<\/a> (brighthub.com)<\/li>\n<li class=\"zemanta-article-ul-li\"><a href=\"http:\/\/www.brighthub.com\/internet\/web-development\/articles\/32445.aspx\">Reasons to Avoid Frames in your Web Design<\/a> (brighthub.com)<\/li>\n<\/ul>\n<div class=\"zemanta-pixie\"><img decoding=\"async\" class=\"zemanta-pixie-img\" src=\"http:\/\/img.zemanta.com\/pixy.gif?x-id=8eec0beb-28e8-4348-be9c-a4bcfc3d694d\" alt=\"\" \/><span class=\"zem-script more-related pretty-attribution\"><script src=\"http:\/\/static.zemanta.com\/readside\/loader.js\" type=\"text\/javascript\"><\/script><\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>When I was first starting out in Web design, I quickly learned that updating your site&#8217;s menus can become a major chore rather quickly. Since I liked to hard-code everything, I only knew a couple main options, neither of which were great: Update every page manually: This works out for a while, but when you&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[68,69,70,71],"class_list":["post-120","post","type-post","status-publish","format-standard","hentry","category-geek","tag-frames","tag-menu-creation","tag-search-engines","tag-web-programming"],"_links":{"self":[{"href":"http:\/\/awgentry.com\/weblog\/wp-json\/wp\/v2\/posts\/120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/awgentry.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/awgentry.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/awgentry.com\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/awgentry.com\/weblog\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":0,"href":"http:\/\/awgentry.com\/weblog\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"wp:attachment":[{"href":"http:\/\/awgentry.com\/weblog\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/awgentry.com\/weblog\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/awgentry.com\/weblog\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}