<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FunkyTower &#187; PHP</title>
	<atom:link href="http://www.davidcrandall.com/categories/web-design/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidcrandall.com</link>
	<description>A great source for tech news, tech help, tech info, and quality web design solutions</description>
	<lastBuildDate>Tue, 18 Aug 2009 08:38:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Website Performance Tips pt. 1: Templating</title>
		<link>http://www.davidcrandall.com/2008/08/07/website-performance-tips-pt-1-templating/</link>
		<comments>http://www.davidcrandall.com/2008/08/07/website-performance-tips-pt-1-templating/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 02:18:13 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Faster]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Template]]></category>

		<guid isPermaLink="false">http://funkytower.com/?p=267</guid>
		<description><![CDATA[Do you have a website, blog, or message board online?  Designing it yourself?  Awesome!  That&#8217;s really wonderful to hear!  What&#8217;s that?  You say your website moves slowly compared to other websites with just as much, if not more content?  Well here are some tips to get your website running smoothely and quickly! Templating/Dividing with PHP:  [...]]]></description>
			<content:encoded><![CDATA[<p>Do you have a website, blog, or message board online?  Designing it yourself?  Awesome!  That&#8217;s really wonderful to hear!  What&#8217;s that?  You say your website moves slowly compared to other websites with just as much, if not more content?  Well here are some tips to get your website running smoothely and quickly!</p>
<p><span id="more-267"></span>Templating/Dividing with PHP:  Though sometimes a little bit of a hassle to set up, it&#8217;s well worth it in the end.  It&#8217;s really not that hard, and it doesn&#8217;t require very much knowlege of PHP programming, either. </p>
<p>In most websites, the only thing that changes is the body of the web page; the header, footer, and sometimes even a sidebar, all stay the same.  Instead of a browser constantly having to reload the same thing on different page do this:</p>
<p>Create a full webpage template containing your header, a place for your main content, and your footer.  Include a sidebar if desired.</p>
<p>Use footnotes to lable the beginning and end of the different areas of your website.  To see an example, view the source of this website.  I left the footnotes in here to show how I templated this website. </p>
<p>OR, here&#8217;s a little tutorial for you which I&#8217;ll be the code I copied straight from my template (without the CSS.) </p>
<blockquote><p>1.  First, and paste it into a text editor or your web design software like Dreamweaver, then save it as sample.html:</p>
<ul>
<li><em><strong>HTML CODE:</strong><br />
&lt;!&#8211; Start Header &#8211;&gt;<br />
&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;<br />
&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=utf-8&#8243; /&gt;<br />
&lt;title&gt;FunkyTower&lt;/title&gt;<br />
&lt;/head&gt;<br />
</em><em>&lt;body&gt;<br />
&lt;div id=&#8221;templateheader&#8221;&gt;&lt;table width=&#8221;100%&#8221; border=&#8221;0&#8243; cellspacing=&#8221;0&#8243; cellpadding=&#8221;0&#8243; id=&#8221;backhead&#8221;&gt;<br />
  &lt;tr&gt;<br />
    &lt;td&gt;&lt;div align=&#8221;center&#8221;&gt;<br />
      &lt;table width=&#8221;1000&#8243; border=&#8221;0&#8243; cellspacing=&#8221;0&#8243; cellpadding=&#8221;0&#8243; id=&#8221;header&#8221;&gt;<br />
        &lt;tr&gt;<br />
          &lt;td valign=&#8221;bottom&#8221;&gt;&lt;table width=&#8221;400&#8243; border=&#8221;0&#8243; cellspacing=&#8221;0&#8243; cellpadding=&#8221;0&#8243; id=&#8221;navbar&#8221;&gt;<br />
            &lt;tr&gt;<br />
              &lt;td&gt;&lt;a href=&#8221;http://www.funkytower.com&#8221; class=&#8221;navbar&#8221;&gt;Home&lt;/a&gt;&lt;/td&gt;<br />
              &lt;td&gt;&lt;a href=&#8221;http://www.funkytower.com/webdesign&#8221; class=&#8221;navbar&#8221;&gt;Web Design&lt;/a&gt;&lt;/td&gt;<br />
              &lt;td&gt;&lt;a href=&#8221;http://www.funkytower.com/about&#8221; class=&#8221;navbar&#8221;&gt;About&lt;/a&gt;&lt;/td&gt;<br />
              &lt;td&gt;&lt;a href=&#8221;http://www.funkytower.com/contact&#8221; class=&#8221;navbar&#8221;&gt;Contact&lt;/a&gt;&lt;/td&gt;<br />
              &lt;td&gt;&lt;a href=&#8221;http://www.funkytower.com/faq&#8221; class=&#8221;navbar&#8221;&gt;FAQ&lt;/a&gt;&lt;/td&gt;<br />
            &lt;/tr&gt;<br />
          &lt;/table&gt;&lt;/td&gt;<br />
        &lt;/tr&gt;<br />
      &lt;/table&gt;<br />
    &lt;/div&gt;&lt;/td&gt;<br />
  &lt;/tr&gt;<br />
&lt;/table&gt;<br />
&lt;/div&gt;<br />
&lt;div align=&#8221;center&#8221;&gt;&lt;br /&gt;<br />
  &lt;!&#8211; End Header &#8211;&gt;<br />
 <br />
  &lt;!&#8211;begin body &#8211;&gt;<br />
  &lt;br /&gt;<br />
&lt;/div&gt;<br />
&lt;table width=&#8221;1000&#8243; border=&#8221;0&#8243; align=&#8221;center&#8221; cellpadding=&#8221;0&#8243; cellspacing=&#8221;0&#8243; id=&#8221;contentholder&#8221;&gt;<br />
  &lt;tr&gt;<br />
    &lt;td&gt;&lt;div align=&#8221;center&#8221;&gt;<br />
      &lt;table width=&#8221;935&#8243; border=&#8221;0&#8243; cellpadding=&#8221;0&#8243; cellspacing=&#8221;0&#8243; id=&#8221;contentholder2&#8243;&gt;<br />
        &lt;tr&gt;<br />
          &lt;td align=&#8221;right&#8221; valign=&#8221;top&#8221;&gt;&lt;/td&gt;<br />
          &lt;td align=&#8221;right&#8221; valign=&#8221;top&#8221;&gt;&lt;/td&gt;<br />
        &lt;/tr&gt;<br />
        &lt;tr&gt;<br />
          &lt;td width=&#8221;581&#8243; valign=&#8221;top&#8221;&gt;&lt;div align=&#8221;center&#8221;&gt;<br />
            &lt;table width=&#8221;565&#8243; border=&#8221;0&#8243; align=&#8221;left&#8221; cellpadding=&#8221;0&#8243; cellspacing=&#8221;0&#8243; id=&#8221;contentmiddle2&#8243;&gt;<br />
              &lt;tr&gt;<br />
                &lt;td id=&#8221;contentheader&#8221;&gt;&amp;nbsp;&lt;/td&gt;<br />
              &lt;/tr&gt;<br />
              &lt;tr&gt;<br />
                &lt;td id=&#8221;contentmiddle&#8221;&gt;&lt;div class=&#8221;content&#8221; id=&#8221;content&#8221;&gt;<br />
                  &lt;h1&gt;Welcome&lt;/h1&gt;<br />
                  &lt;p&gt;Hello and Welcome to FunkyTower! &lt;/p&gt;<br />
                  &lt;p&gt;Have a great day!&lt;br /&gt;<br />
                    &lt;a href=&#8221;mailTo:david@funkytower.com&#8221;&gt;Linke Test&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;/td&gt;<br />
              &lt;/tr&gt;<br />
              &lt;tr&gt;<br />
                &lt;td id=&#8221;contentfooter&#8221;&gt;&amp;nbsp;&lt;/td&gt;<br />
              &lt;/tr&gt;<br />
            &lt;/table&gt;<br />
          &lt;/div&gt;&lt;/td&gt;&lt;!&#8211; End Body &#8211;&gt;<br />
          &lt;!&#8211; Start Sidebar&#8211;&gt;<br />
          &lt;td width=&#8221;354&#8243; valign=&#8221;top&#8221;&gt;&lt;table width=&#8221;327&#8243; border=&#8221;0&#8243; align=&#8221;right&#8221; cellpadding=&#8221;0&#8243; cellspacing=&#8221;0&#8243; id=&#8221;sidebartable&#8221;&gt;<br />
            &lt;tr&gt;<br />
              &lt;td valign=&#8221;top&#8221;&gt;&lt;p align=&#8221;right&#8221;&gt;<br />
                &lt;input name=&#8221;s&#8221; type=&#8221;text&#8221; id=&#8221;s&#8221; value=&#8221;" size=&#8221;30&#8243; class=&#8221;searchbar&#8221; /&gt;<br />
                &lt;input type=&#8221;submit&#8221; id=&#8221;searchsubmit&#8221; value=&#8221;" class=&#8221;search&#8221; /&gt;<br />
                &lt;/p&gt;&lt;/td&gt;<br />
            &lt;/tr&gt;<br />
            &lt;tr&gt;<br />
              &lt;td valign=&#8221;top&#8221;&gt;&lt;div id=&#8221;sidebar&#8221; class=&#8221;sidebar&#8221;&gt;&lt;img alt=&#8221;" src=&#8221;images/archivestitle.jpg&#8221; width=&#8221;327&#8243; height=&#8221;58&#8243; /&gt;<br />
                &lt;ul&gt;<br />
                  &lt;li&gt;July 2008&lt;/li&gt;<br />
                  &lt;li&gt;August 2008&lt;/li&gt;<br />
                  &lt;li&gt;September 2008&lt;/li&gt;<br />
                &lt;/ul&gt;<br />
                &lt;img alt=&#8221;" src=&#8221;images/categoriesheader.jpg&#8221; width=&#8221;327&#8243; height=&#8221;59&#8243; /&gt;<br />
                &lt;ul&gt;<br />
                  &lt;li&gt;Category 1&lt;/li&gt;<br />
                  &lt;li&gt;Category 2&lt;/li&gt;<br />
                  &lt;li&gt;Category 3&lt;/li&gt;<br />
                  &lt;li&gt;Category 4&lt;/li&gt;<br />
                  &lt;li&gt;Category 5&lt;/li&gt;<br />
                  &lt;li&gt;Category 6&lt;/li&gt;<br />
                &lt;/ul&gt;&lt;/div&gt;&lt;/td&gt;<br />
            &lt;/tr&gt;<br />
          &lt;/table&gt;&lt;/td&gt;<br />
        &lt;/tr&gt;<br />
      &lt;/table&gt;<br />
    &lt;/div&gt;&lt;/td&gt;<br />
  &lt;/tr&gt;<br />
&lt;/table&gt;<br />
&lt;!&#8211; End sidebar &#8211;&gt;<br />
&lt;!&#8211; Begin Footer &#8211;&gt;&lt;br /&gt;&lt;br /&gt;<br />
&lt;table width=&#8221;100%&#8221; border=&#8221;0&#8243; cellpadding=&#8221;0&#8243; cellspacing=&#8221;0&#8243; id=&#8221;footercontainer&#8221;&gt;<br />
  &lt;tr&gt;<br />
    &lt;td&gt;&lt;div align=&#8221;center&#8221;&gt;<br />
      &lt;table width=&#8221;935&#8243; border=&#8221;0&#8243; cellpadding=&#8221;0&#8243; cellspacing=&#8221;0&#8243; id=&#8221;footer&#8221;&gt;<br />
        &lt;tr&gt;<br />
          &lt;td width=&#8221;468&#8243;&gt;Stuff and more stuff will go here&lt;/td&gt;<br />
          &lt;td width=&#8221;467&#8243;&gt;Then we&#8217;ll have more stuff right here as well!&lt;/td&gt;<br />
        &lt;/tr&gt;<br />
        &lt;tr&gt;<br />
          &lt;td colspan=&#8221;2&#8243;&gt;&lt;div align=&#8221;center&#8221; class=&#8221;credit&#8221;&gt;Blah blah&lt;/div&gt;&lt;/td&gt;<br />
          &lt;/tr&gt;<br />
      &lt;/table&gt;<br />
    &lt;/div&gt;&lt;/td&gt;<br />
  &lt;/tr&gt;<br />
&lt;/table&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
&lt;!&#8211;End Footer&#8211;&gt;<br />
</em></li>
</ul>
<p>So you can clearly see where each section starts and ends. </p>
<p>2.  The next step is to divide the template into four PHP documents: header.php, body.php, sidebar.php, and footer.php</p>
<p>To do this, Highlight, rightclick, and cut  All the code from &#8220;&lt;!&#8211;Start Header&#8211;&gt;&#8221; to &#8220;&lt;!&#8211;End Header&#8211;&gt;&#8221;<br />
Paste the code into a new document in notepad and save it as &#8220;header.php&#8221;</p>
<p>3.  Next, cut all the code from &lt;!&#8211;begin body&#8211;&gt; to &lt;!&#8211;End body&#8211;&gt;<br />
Paste this code into a NEW document in notepad and save it as &#8220;body.php&#8221;</p>
<p>4.  Do the same steps for the sidebar and the footer, naming them &#8220;sidebar.php&#8221; and &#8220;footer.php&#8221;.</p>
<p>Now you should have four separate documents for your template: header.php, body.php, sidebar.php, and footer.php<br />
These files must all be in the same folder.</p>
<p>Now all that&#8217;s left to do is create a PHP file that calls all your other php files to form one page using &lt;?php require( ) ?&gt;</p>
<p> </p>
<p>5.  Open up a new notepad document and paste the following code into it:</p>
<ul>
<li><strong></strong><br />
<em>&lt;?php require(&#8216;header.php&#8217;) ?&gt;<br />
&lt;?php require(&#8216;body.php&#8217;) ?&gt;<br />
&lt;?php require(&#8216;sidebar.php&#8217;) ?&gt;<br />
&lt;?php require(&#8216;footer.php&#8217;) ?&gt;</em></li>
</ul>
<p>6.  Save it as &#8220;test.php&#8221; to the same folder location/directory as you did all the other files, or upload all the files to one folder/directory on your server.</p></blockquote>
<p>That&#8217;s it!  Now you should have a full web page that looks just like the &#8220;template.html&#8221; file we made!  Using this method will allow your visitors to only have to load your header, footer, and sidebar just one time! </p>
<p>Now, If you want to make different web pages, copy your &#8220;body.php&#8221; file and change  the content within it, and save it as a new php file like content1.php.  Then, take your &#8220;test.php&#8221; change &#8216;body.php&#8217; to &#8216;content1.php&#8217; and save the document as &#8220;page1.php&#8221; or &#8220;index.php&#8221; <img src='http://www.davidcrandall.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>On top of making your website load faster, this also allows editing to be alot simpler.  Say you made a new page and had to edit the sidebar or header so that you could add a link to that page.  Well, instead of editing SEVERAL pages to have the same effect, you just have to edit one, and it effects ALL your web pages! <img src='http://www.davidcrandall.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Cool, huh?</p>
<p> </p>
<p><strong>What Do You Think<br />
</strong>Did this tutorial help you?  Did you learn something new?  Have more tips to make your website run smoother and faster?  Still need help?  Let me know!  Send your questions and knowlege to <a href="mailto:david@funkytower.com">david@funkytower.com</a>! I look forward to hearing from you <img src='http://www.davidcrandall.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://funkytower.com/2008/08/07/website-performance-tips-pt-2-css-validation-multiple-browsers-and-image-optimization/"><strong>Continue on to Part 2 for more tips on how to make your website move fast and smooth.</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcrandall.com/2008/08/07/website-performance-tips-pt-1-templating/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
