{"id":1894,"date":"2010-11-22T06:51:08","date_gmt":"2010-11-22T11:51:08","guid":{"rendered":"http:\/\/www.killersites.com\/magazine\/?p=1894"},"modified":"2010-11-07T19:51:53","modified_gmt":"2010-11-08T00:51:53","slug":"killersites-forum-blog-repeating-sections-of-code-on-many-pages","status":"publish","type":"post","link":"http:\/\/www.killersites.com\/magazine\/2010\/killersites-forum-blog-repeating-sections-of-code-on-many-pages\/","title":{"rendered":"Killersites Forum Blog &#8211; Repeating Sections of Code On Many Pages"},"content":{"rendered":"<p><a href=\"http:\/\/www.killersites.com\/magazine\/wp-content\/uploads\/2010\/11\/108.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.killersites.com\/magazine\/wp-content\/uploads\/2010\/11\/108.png\" alt=\"Forum\" title=\"Forum\" width=\"128\" height=\"128\" class=\"alignright size-full wp-image-1887\" \/><\/a><br \/>\nHey Everyone,<\/p>\n<p>This week on The Killersites Forum Blog, we take a look at a really insightful post from the <a href=\"http:\/\/www.killersites.com\/community\/\">Killersites Forum<\/a> on how to create repeating sections of code on numerous pages.<\/p>\n<p><a href=\"http:\/\/www.killersites.com\/community\/index.php?%2Ftopic%2F304-repeating-sections-of-code-on-many-pages%2F\"><strong>Repeating Sections of Code On Many Pages <\/strong><\/a><\/p>\n<p><strong>Question:<\/strong>&#8211; I&#8217;ve got a site with 100 pages and I don&#8217;t want to edit the<br \/>\nmenu on every page.<\/p>\n<p><strong>Answer:<\/strong>&#8211; Form one page complete in the normal way with the menu and<br \/>\ncheck that it validates and displays properly.<\/p>\n<p>Open up Notepad or a text editor (not Word) and cut the code that<br \/>\nrepeats in every page completely (as much or as little as you want,<br \/>\nwithout doctype, html, head or body tags) and paste it into Notepad and<br \/>\nsave as an &#8220;include&#8221; file called menu.inc. You then have only one file to<br \/>\nedit if the menu changes.<\/p>\n<p>Substitute the code you have cut out with PHP code<\/p>\n<p>in the main file and save it with .php filename extension instead of .html<br \/>\nor .htm.<\/p>\n<p>Do the same with other main pages where the menu repeats.<br \/>\nYou can use .txt, .php, .html or .htm for the &#8220;include&#8221; file but it<br \/>\ndistinguishes it as an &#8220;include&#8221; file in your file list if you use .inc as the<br \/>\nfilename extension and it&#8217;s even better if you put all &#8220;include&#8221; files in a<br \/>\ndifferent directory\/folder.<\/p>\n<p>If you use a complete page as an &#8220;include&#8221; file with .html or .htm for the<br \/>\nfilename extension the final processed page will have two doctypes, two<br \/>\nhtml tags, two head sections, etc. in an unusual place which is not a<br \/>\ngood idea.<\/p>\n<p>You can have different &#8220;include&#8221; files on the same main pages for header<br \/>\nand footer and even use &#8220;includes&#8221; for the parts of the head section that<br \/>\nrepeat.<\/p>\n<p>The PHP code needs to be processed by a server before the result can<br \/>\nbe seen, either by the hosting service&#8217;s server just before downloading or<br \/>\nby a server like WAMP (which includes Apache) on your computer for<br \/>\nlocal viewing.<\/p>\n<p>SHTML works the same way but the &#8220;include&#8221; file must have .txt<br \/>\nfilename extension and the main pages have the code and the .shtml filename extension.<\/p>\n<p>Check that your hosting service supports PHP or SHTML as free<br \/>\nwebspaces provided by ISPs usually do not.<\/p>\n<p>Stefan has 2 great video tutorials explaining exactly this in the PHP tutorials: <a href=\"http:\/\/idea22.com\/video\/details\/id\/200708088306345299\">PHP includes part 1<\/a> and <a href=\"http:\/\/idea22.com\/video\/details\/id\/200708287129879572\">PHP includes part 2<\/a> from the <a href=\"http:\/\/www.killervideostore.com\/video-courses\/beginners-php.php\">PHP Basics Course.<\/a><\/p>\n<p>Not sure if this is in the videos &#8211; but it&#8217;s generally a good idea, especially if the site is set up with sub-folders, to use the absolute paths pointing to the include files, and for anything the include itself points to &#8211; that can save a lot of wondering why something suddenly isn&#8217;t showing up. <\/p>\n<p><strong>Written by: Wickham<\/strong><\/p>\n<p>You can take a look and get involved with <a href=\"http:\/\/www.killersites.com\/community\/index.php?%2Ftopic%2F304-repeating-sections-of-code-on-many-pages%2F\">the original post and discussions here!<\/a><\/p>\n<p>Thanks,<\/p>\n<p>Jody<br \/>\nKillersites.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey Everyone, This week on The Killersites Forum Blog, we take a look at a really insightful post from the Killersites Forum on how to create repeating sections of code on numerous pages. Repeating Sections of Code On Many Pages Question:&#8211; I&#8217;ve got a site with 100 pages and I don&#8217;t want to edit the [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[93],"tags":[68,90,189],"_links":{"self":[{"href":"http:\/\/www.killersites.com\/magazine\/wp-json\/wp\/v2\/posts\/1894"}],"collection":[{"href":"http:\/\/www.killersites.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.killersites.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.killersites.com\/magazine\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"http:\/\/www.killersites.com\/magazine\/wp-json\/wp\/v2\/comments?post=1894"}],"version-history":[{"count":12,"href":"http:\/\/www.killersites.com\/magazine\/wp-json\/wp\/v2\/posts\/1894\/revisions"}],"predecessor-version":[{"id":1908,"href":"http:\/\/www.killersites.com\/magazine\/wp-json\/wp\/v2\/posts\/1894\/revisions\/1908"}],"wp:attachment":[{"href":"http:\/\/www.killersites.com\/magazine\/wp-json\/wp\/v2\/media?parent=1894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.killersites.com\/magazine\/wp-json\/wp\/v2\/categories?post=1894"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.killersites.com\/magazine\/wp-json\/wp\/v2\/tags?post=1894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}