<?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>Lacquer Head &#187; PHP</title>
	<atom:link href="http://lacquerhead.ca/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://lacquerhead.ca</link>
	<description>Meat and Computers</description>
	<lastBuildDate>Tue, 12 Jan 2010 21:40:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting Other Applications to Work with Wordpress Users</title>
		<link>http://lacquerhead.ca/2009/07/getting-other-applications-to-work-with-wordpress-users/</link>
		<comments>http://lacquerhead.ca/2009/07/getting-other-applications-to-work-with-wordpress-users/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 19:59:46 +0000</pubDate>
		<dc:creator>laqrhead</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://lacquerhead.ca/?p=175</guid>
		<description><![CDATA[Sometimes a wordpress plugin is not the proper solution for an complex application. You might want something to work alongside wordpress instead. One of the nice features of Worpress is the user managament. The Wordpress documentation for this is non-existant as far as I ca tell, so here&#8217;s how you can quickly have your software [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes a wordpress plugin is not the proper solution for an complex application. You might want something to work alongside wordpress instead. One of the nice features of Worpress is the user managament. The Wordpress documentation for this is non-existant as far as I ca tell, so here&#8217;s how you can quickly have your software find out if a user is logged in outside of Wordpress.<span id="more-175"></span></p>
<p>Wordpress stores the user&#8217;s login status in a cookie named &#8220;wordpress_logged_in_COOKIEHASH,&#8221; Where COOKIEHASH there is  an MD5 hash of the &#8216;Site URL&#8217; option. Line 421 of wp-settings.php:</p>
<p><code><br />
define('COOKIEHASH', md5(get_option('siteurl')));<br />
</code></p>
<p>So you can use that to check the cookie, or  you can copy it from an existing cookie on your machine, or generate it in your own cookie name. First, log yourself out of Wordpress, because we are going to be changing the logged in cookie name, and you won&#8217;t be able to log in or out with the old cookie name. Now we can define a new cookie name in the wp-config.php file by adding the following line somewhere in the file:</p>
<p><code>define('LOGGED_IN_COOKIE', 'my_cookie_name');</code></p>
<p>For Reference The default is defined in wp-settings.php on line 392 as:</p>
<p><code>define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);</code></p>
<p>So now I&#8217;ll always know what the cookie name is, so I can extract the username from the cookie value.</p>
<p>The value contains the following info:</p>
<p>username|doubleHashedPassword</p>
<p>Now that we have a username, we can fetch user data, such as a user_id. Something like this should do the trick assuming that you have established your DB connection:</p>
<p><code><?php<br />
if (!empty($_COOKIE[my_cookie_name])) {</p>
<p>    // The user is logged in, so retrieve user data<br />
    $userArr=explode('|',$_COOKIE[my_cookie_name]);<br />
    $user_login=$userArr[0];</p>
<p>    $sql="SELECT ID FROM wp_users WHERE user_login LIKE '$user_login'";<br />
    $query=mysql_query($sql);<br />
    $resultArray=mysql_fetch_array($query);<br />
    $user_id=$resultArray[ID];</p>
<p>} else {</p>
<p>    // The user is not logged in so do something else</p>
<p>}<br />
?></code></p>
<p>That should work.</p>
]]></content:encoded>
			<wfw:commentRss>http://lacquerhead.ca/2009/07/getting-other-applications-to-work-with-wordpress-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wordpress RSS Feed Error</title>
		<link>http://lacquerhead.ca/2009/06/wordpress-rss-feed-error/</link>
		<comments>http://lacquerhead.ca/2009/06/wordpress-rss-feed-error/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:38:11 +0000</pubDate>
		<dc:creator>laqrhead</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://lacquerhead.ca/?p=143</guid>
		<description><![CDATA[You ever get an error like this from your feeds generated by Wordpress?
XML Parsing Error: XML or text declaration not at start of entity
Location: http://www.yoursite.tld/utils/test.xml
Line Number 2, Column 1:&#60;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&#62;
Somewhere along the line a new line was being placed before the XML declaration in the feeds. This caused an error to display in Firefox [...]]]></description>
			<content:encoded><![CDATA[<p>You ever get an error like this from your feeds generated by Wordpress?</p>
<blockquote><p>XML Parsing Error: XML or text declaration not at start of entity<br />
Location: http://www.yoursite.tld/utils/test.xml<br />
Line Number 2, Column 1:&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;</p></blockquote>
<p>Somewhere along the line a new line was being placed before the XML declaration in the feeds. This caused an error to display in Firefox and other browsers instead of the feed.<span id="more-143"></span></p>
<p>I searched high and low to find where it was coming from. Disabled all me plugins, removed blank lines from code etc. To no avail. Then I noticed that the error was happening on a Mac but not in Windows. So it had to do with something about how Windows, Mac, and Linux/Unix deal with carriage returns and new line characters. I didn&#8217;t think I&#8217;d ever find the ghost new line (or return) so I tried to find a way to delete it.</p>
<p>Here is the hack/fix. What I&#8217;ve done is start an output buffer, and then clear it before the XML/RSS template is loaded.</p>
<p>In the index.php file put ob_start() like this:</p>
<blockquote><p><code>&lt;?php<br />
ob_start();</code></p></blockquote>
<p>In wp-includes/functions.php add ob_end_clean() to the beginning functions that load the feed templates.</p>
<blockquote><p><code><br />
/**<br />
* Load the RDF RSS 0.91 Feed template.<br />
*<br />
* @since 2.1.0<br />
*/<br />
function do_feed_rdf() {<br />
ob_end_clean();<br />
load_template( ABSPATH . WPINC . '/feed-rdf.php' );<br />
}</code></p>
<p>/**<br />
* Load the RSS 1.0 Feed Template<br />
*<br />
* @since 2.1.0<br />
*/<br />
function do_feed_rss() {<br />
ob_end_clean();<br />
load_template( ABSPATH . WPINC . &#8216;/feed-rss.php&#8217; );<br />
}</p>
<p>/**<br />
* Load either the RSS2 comment feed or the RSS2 posts feed.<br />
*<br />
* @since 2.1.0<br />
*<br />
* @param bool $for_comments True for the comment feed, false for normal feed.<br />
*/<br />
function do_feed_rss2( $for_comments ) {<br />
ob_end_clean();<br />
if ( $for_comments )<br />
load_template( ABSPATH . WPINC . &#8216;/feed-rss2-comments.php&#8217; );<br />
else<br />
load_template( ABSPATH . WPINC . &#8216;/feed-rss2.php&#8217; );<br />
}</p>
<p>/**<br />
* Load either Atom comment feed or Atom posts feed.<br />
*<br />
* @since 2.1.0<br />
*<br />
* @param bool $for_comments True for the comment feed, false for normal feed.<br />
*/<br />
function do_feed_atom( $for_comments ) {<br />
ob_end_clean();<br />
if ($for_comments)<br />
load_template( ABSPATH . WPINC . &#8216;/feed-atom-comments.php&#8217;);<br />
else<br />
load_template( ABSPATH . WPINC . &#8216;/feed-atom.php&#8217; );<br />
}</p></blockquote>
<p>This worked without the change to the index.php file, but I don&#8217;t think it should have.</p>
<p>I tried to accomplish this with a plugin, but it wouldn&#8217;t work. since this is editing Wordpress core files, these changes will need to be made again after an upgrade if the problem persists with the new version.</p>
]]></content:encoded>
			<wfw:commentRss>http://lacquerhead.ca/2009/06/wordpress-rss-feed-error/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Duplicate Category Names in Wordpress</title>
		<link>http://lacquerhead.ca/2009/06/duplicate-category-names-in-wordpress/</link>
		<comments>http://lacquerhead.ca/2009/06/duplicate-category-names-in-wordpress/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 20:18:09 +0000</pubDate>
		<dc:creator>laqrhead</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[slug]]></category>

		<guid isPermaLink="false">http://lacquerhead.ca/?p=62</guid>
		<description><![CDATA[I was having some issues adding sub-categories that had duplicate names, but unique slugs. I don&#8217;t know if this is a bug or a feature, but since the slug is the unique key, it doesn&#8217;t make sense to me why you couldn&#8217;t be able to have duplicate names if the slug is unique. Anyways, here [...]]]></description>
			<content:encoded><![CDATA[<p>I was having some issues adding sub-categories that had duplicate names, but unique slugs. I don&#8217;t know if this is a bug or a feature, but since the slug is the unique key, it doesn&#8217;t make sense to me why you couldn&#8217;t be able to have duplicate names if the slug is unique. Anyways, here is a hack, not a plugin, <em>so you&#8217;ll need to fix it again if you update Wordpress.</em><span id="more-62"></span></p>
<p>To allow duplicate names, but keep unique slugs, find the following code (lines 312-318) in wp-admin/admin-ajax.php:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span> category_exists<span class="br0">&#40;</span> <a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span> <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;cat_name&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$x</span> = <span class="kw2">new</span> WP_Ajax_Response<span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;what&#8217;</span> =&gt; <span class="st0">&#8216;cat&#8217;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;id&#8217;</span> =&gt; <span class="kw2">new</span> WP_Error<span class="br0">&#40;</span> <span class="st0">&#8216;cat_exists&#8217;</span>, __<span class="br0">&#40;</span><span class="st0">&#8216;The category you are trying to create already exists.&#8217;</span><span class="br0">&#41;</span>, <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;form-field&#8217;</span> =&gt; <span class="st0">&#8216;cat_name&#8217;</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$x</span>-&gt;<span class="me1">send</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>Replace with this code:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span> category_exists<span class="br0">&#40;</span> <a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span> <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;category_nicename&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$x</span> = <span class="kw2">new</span> WP_Ajax_Response<span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;what&#8217;</span> =&gt; <span class="st0">&#8216;cat&#8217;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;id&#8217;</span> =&gt; <span class="kw2">new</span> WP_Error<span class="br0">&#40;</span> <span class="st0">&#8216;cat_exists&#8217;</span>, __<span class="br0">&#40;</span><span class="st0">&#8216;The category you are trying to create already exists.&#8217;</span><span class="br0">&#41;</span>, <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;form-field&#8217;</span> =&gt; <span class="st0">&#8216;category_nicename&#8217;</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$x</span>-&gt;<span class="me1">send</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>What you are doing is changing the instances of &#8220;cat_name&#8221; with &#8220;category_nicename&#8221;, This has it check the slug for uniqueness, and not the name.</p>
<p>I tested briefly for myself and it seems to be working.</p>
]]></content:encoded>
			<wfw:commentRss>http://lacquerhead.ca/2009/06/duplicate-category-names-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server Side, Making Your Life Easier: UPDATE</title>
		<link>http://lacquerhead.ca/2009/06/server-side-making-your-life-easier-update/</link>
		<comments>http://lacquerhead.ca/2009/06/server-side-making-your-life-easier-update/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 21:48:33 +0000</pubDate>
		<dc:creator>laqrhead</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://lacquerhead.ca/?p=39</guid>
		<description><![CDATA[In the previous articles, I used a PHP shortcut to display variables. Just like this:
&#60;?=$variable?&#62;
That method, although very friendly and quick, is deprecated, so you should get used to doing this instead:
&#60;?php echo $variable; ?&#62;
I&#8217;ll keep you posted if I com up with anything else.
]]></description>
			<content:encoded><![CDATA[<p>In the previous articles, I used a PHP shortcut to display variables. Just like this:</p>
<p>&lt;?=$variable?&gt;</p>
<p>That method, although very friendly and quick, is deprecated, so you should get used to doing this instead:</p>
<p>&lt;?php echo $variable; ?&gt;</p>
<p>I&#8217;ll keep you posted if I com up with anything else.</p>
]]></content:encoded>
			<wfw:commentRss>http://lacquerhead.ca/2009/06/server-side-making-your-life-easier-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server Side, Making Your Life Easier: Part 3 &#8211; PHP Headers and Footers with Defaults</title>
		<link>http://lacquerhead.ca/2009/06/php-headers-and-footers-with-defaults/</link>
		<comments>http://lacquerhead.ca/2009/06/php-headers-and-footers-with-defaults/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 21:42:24 +0000</pubDate>
		<dc:creator>laqrhead</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://lacquerhead.ca/?p=36</guid>
		<description><![CDATA[As I mentioned in my previous post, there are some old deprecated things here, I&#8217;ll update later.
You now know how to create and display variables with PHP. Here is a review of everything I’ve used so far.
How to break in and out of PHP:



&#60;?php


//PHP Code Goes Here


?&#62;



How to set a variable:



&#60;?php


$variable = &#34;Variable Value&#34;;


?&#62;



How to [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>As I mentioned in my previous post, there are some old deprecated things here, I&#8217;ll update later.</em></p></blockquote>
<p>You now know how to create and display variables with PHP. Here is a review of everything I’ve used so far.</p>
<p>How to break in and out of PHP:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//PHP Code Goes Here</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>How to set a variable:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$variable</span> = <span class="st0">&quot;Variable Value&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>How to quickly display a variable:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?</span>=<span class="re0">$variable</span>?&gt;</div>
</li>
</ol>
</div>
<p>Now we are going to use &#8220;if,&#8221; &#8220;else,&#8221; and &#8220;echo&#8221; to set default values for the title, and meta tags. There won’t be a step by step process for this one, I’m just gonna display the sample code for header.php. Everything else is done almost exactly the same as Part 2.<span id="more-36"></span></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;html&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;head&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;title&gt;&lt;?php</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$title</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;$title&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;Site Title &#8211; Tagline&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">?&gt;&lt;/title&gt;</div>
</li>
<li class="li2">
<div class="de2">&lt;meta name=<span class="st0">&quot;description&quot;</span> content=<span class="st0">&quot;&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">if ($description) {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">echo &quot;</span><span class="re0">$description</span><span class="st0">&quot;;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">} else {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">echo &quot;</span><span class="kw2">Default</span> META Description<span class="st0">&quot;;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="st0">}</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">?&gt;&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;meta name=<span class="st0">&quot;keywords&quot;</span> content=<span class="st0">&quot;&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">if ($keywords) {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">echo &quot;</span><span class="re0">$keywords</span><span class="st0">&quot;;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="st0">} else {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">echo &quot;</span><span class="kw2">Default</span> META Keywords<span class="st0">&quot;;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">}</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">?&gt;&quot;</span>&gt;</div>
</li>
</ol>
</div>
<p>Now, if you want to use the default values, just remove the line that sets the variable from the content page. You can also comment out the line to add it back in later. The following example will only pass on a unique title to the header.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$title</span> = <span class="st0">&quot;Page Title Goes Here&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//$description = &quot;Page Description Goes Here &quot;;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//$keywords = &quot;Page Keywords Go Here &quot;;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">include</span><span class="br0">&#40;</span><span class="st0">&#8216;header.php&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>Thats it, this will make your life easier. This should also give you a good start to using simple PHP. There are many more area’s of server side scripting you should explore. It will replace buggy, error prone client side scripting in many ways, such as; Browser Detects, Redirections, Cookies, Form Validation, and much more. If you are already familiar with JavaScript, PHP will be a breeze.</p>
]]></content:encoded>
			<wfw:commentRss>http://lacquerhead.ca/2009/06/php-headers-and-footers-with-defaults/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server Side, Making Your Life Easier: Part 2 &#8211; PHP Headers and Footers</title>
		<link>http://lacquerhead.ca/2009/06/part-2-php-headers-and-footers/</link>
		<comments>http://lacquerhead.ca/2009/06/part-2-php-headers-and-footers/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 21:34:34 +0000</pubDate>
		<dc:creator>laqrhead</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://lacquerhead.ca/?p=32</guid>
		<description><![CDATA[This is an older tutorial and contains deprecated PHP code. I&#8217;ll revisit this in the near future to elaborate.
PHP is great because not only will it allow you to insert files like SSIs, it allows you to easily pass variables on to them such as a page title (your server must support PHP for this [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>This is an older tutorial and contains deprecated PHP code. I&#8217;ll revisit this in the near future to elaborate.</em></p></blockquote>
<p>PHP is great because not only will it allow you to insert files like SSIs, it allows you to easily pass variables on to them such as a page title (your server must support PHP for this to work). You don’t need to know anything about PHP to use this. This example will show how to do this and pass on individual page titles, descriptions and keywords.<span id="more-32"></span></p>
<p>1. Create a page with headers and footers like you would with server side includes. (see pt. 1 of this post)</p>
<p>I suggest you name the pages header.php, index.php, and footer.php</p>
<p>2. In your header file, replace your title and meta tags with the following:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;title&gt;&lt;?=<span class="re0">$title</span>?&gt;&lt;/title&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;meta name=<span class="st0">&quot;description&quot;</span> content=<span class="st0">&quot;&lt;?=$description?&gt;&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;meta name=<span class="st0">&quot;keywords&quot;</span> content=<span class="st0">&quot;&lt;?=$keywords?&gt;&quot;</span>&gt;</div>
</li>
</ol>
</div>
<p>3. In the index page, put the following at the very top</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$title</span> = <span class="st0">&quot;Page Title Goes Here&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$description</span> = <span class="st0">&quot;Page Description Goes Here &quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$keywords</span> = <span class="st0">&quot;Page Keywords Go Here &quot;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">include</span><span class="br0">&#40;</span><span class="st0">&#8216;header.php&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>and put this at the bottom</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">include</span><span class="br0">&#40;</span><span class="st0">&#8216;footer.php&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>4. Upload to the server and open index.php.</p>
<p>5. Create all of your other pages and use these same tags at the beginning and end, then if you need to change the site in a major way, just edit the header and footer files. This can all be done in a similar fashion in ASP, if anyone wants to now how, let me know and will post instructions.</p>
<p>Thats it, this will make your life easier. There are some drawbacks though. It is not always necessary to change these on every page (It is a good idea to change the title and meta description for every page. It makes your listings in the search engines much more attractive). In Pt. 3 I will show you how set default values so you don’t have to worry about managing keywords and descriptions for every page.</p>
]]></content:encoded>
			<wfw:commentRss>http://lacquerhead.ca/2009/06/part-2-php-headers-and-footers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server Side, Making Your Life Easier: Part 1 &#8211; Server Side Includes</title>
		<link>http://lacquerhead.ca/2009/06/server-side-making-your-life-easier-part-1-server-side-includes/</link>
		<comments>http://lacquerhead.ca/2009/06/server-side-making-your-life-easier-part-1-server-side-includes/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 21:31:13 +0000</pubDate>
		<dc:creator>laqrhead</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://lacquerhead.ca/?p=30</guid>
		<description><![CDATA[Originally posted on the Steel Dolphin Forum a long long time ago.

Many of you know how to use Server Side Includes, and PHP/ASP. I am going to go over a few uses of these that make your life easier. You do not need to already know how to use these though.
The first rule to making [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>Originally posted on the <a href="http://www.steeldolphin.com/">Steel Dolphin</a> Forum a long long time ago.<br />
</em></p></blockquote>
<p>Many of you know how to use Server Side Includes, and PHP/ASP. I am going to go over a few uses of these that make your life easier. You do not need to already know how to use these though.</p>
<p>The first rule to making your life easier as a web designer is changing as few files as possible when you need to make a change. That is why we use a separate CSS and JavaScript file, right? This all can be applied along with one of the philosophies behind XML, keep style separate from content.</p>
<p>This is very easy to do with Server Side Includes. How? Here&#8217;s the steps. (Your web server must support Server Side Includes)</p>
<p><span id="more-30"></span>1. Create your main page for your site as you normally would.</p>
<p>2. Create three html files from that one file, a header, footer, and a file with all of the content (by content I mean the stuff that will change from page to page, like text). The header will contain everything from the first HTML tag to just before where the content begins. The footer will contain everything after the content to the closing HTML tag. And whats left is your content page.</p>
<p>I would name the pages header.html, index.shtml, and footer.html. Notice how the file extension of the index page is SHTML? This will tell the server to scan that page for includes before displaying it.</p>
<p>3. On the first line of index.shtml, insert the following tag,</p>
<p><tt>&lt;!--#include virtual="header.html" --&gt;</tt></p>
<p>and on the last line, insert the following,</p>
<p><tt>&lt;!--#include virtual="footer.html" --&gt;</tt></p>
<p>4. Upload to the server and open index.shtml.</p>
<p>5. Create all of your other pages and use these same tags at the beginning and end, then if you need to change the site in a major way, just edit the header and footer files. Be sure to save each file with the extension &#8220;shtml&#8221;</p>
<p>That’s it, this will make your life easier. There are drawbacks to this though, it will not be easy for you to change your page Titles, or other things usually found at the top of the HTML file. For this you need a server side scripting language like PHP. I will post Pt. 2 with PHP to make your life even easier in a few days.</p>
]]></content:encoded>
			<wfw:commentRss>http://lacquerhead.ca/2009/06/server-side-making-your-life-easier-part-1-server-side-includes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
