<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Robin Parduez | Blog » web design</title>
	
	<link>http://rpardz.com/blog</link>
	<description>Front-end Development Tips &amp; Ramblings</description>
	<lastBuildDate>Mon, 27 Feb 2012 02:14:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		
<cloud domain="rpardz.com" port="80" path="/blog/?rsscloud=notify" registerProcedure="" protocol="http-post" />
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/robinparduez/blog/web-design" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="robinparduez/blog/web-design" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://rpardz.com/blog/?pushpress=hub" /><item>
		<title>Load Social Sharing Buttons via Ajax &amp; jQuery</title>
		<link>http://rpardz.com/blog/load-social-buttons-ajax-jquery/</link>
		<comments>http://rpardz.com/blog/load-social-buttons-ajax-jquery/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 13:10:22 +0000</pubDate>
		<dc:creator>Robin Parduez</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://rpardz.com/blog/?p=1360</guid>
		<description><![CDATA[I&#8217;ve recently been doing a lot of testing to improve page load times using various different techniques. However, I&#8217;ve been finding on my own sites and when I visit others, that social media buttons often cause a lot latency on page loading. When it first launched, there were a lot of complaints about the Google+ [...]<p><hr />
<a href="http://rpardz.com/blog/load-social-buttons-ajax-jquery/">Load Social Sharing Buttons via Ajax &#038; jQuery</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></description>
			<content:encoded><![CDATA[<div class="cols cols2">
<div class="col">
<p>I&#8217;ve recently been doing a lot of testing to improve page load times using various different techniques. However, I&#8217;ve been finding on my own sites and when I visit others, that social media buttons often cause a lot latency on page loading. When it first launched, there were <a href="http://www.seroundtable.com/google-plus-one-slow-13758.html" rel="external">a lot of complaints</a> about the Google+ button slowing down pages significantly. Some SEOs even claimed a drop in rankings, although it&#8217;s difficult to verify this. <em>It&#8217;s worth noting that Google released an updated version of the button which does load faster</em>.</p>
<p>In the past I&#8217;ve covered Google&#8217;s take on <a href="http://rpardz.com/blog/gzip-compression-techniques-better-page-speeds/" rel="external">Page Speed and search rankings</a>, and whether it is becoming a more important feature of the algorithm remains to be seen. Speeding up page load times is good for users, and with rich-media and other bandwidth intensive features on websites continuing to increase, any <em>SEO-friendly</em> way to speed up your pages is a good thing.</p>
</div>
<div class="col">
<p>Like many other website owners, I have added social interaction buttons to my blog posts, but I have never been happy with the extra lag this causes on page loads.</p>
<p>There are several methods being used by various sites that delay the loading of the social buttons until needed. This can be via the lazy loading technique or by using Ajax to call in the buttons when needed. With this in mind, I have worked on my own solution which I&#8217;m going to share with you today.</p>
<p>The following method uses the jQuery framework, and loads the social buttons using an Ajax request when a user hovers over the buttons with their mouse. I have also added a click function for tablets and smartphones, as a mouse hover event is pretty useless on such devices.</p>
</div>
</div>
<p><strong><a href="http://rpardz.com/demos/ajax-social-buttons/" rel="external">View Demo &rarr;</a></strong> <strong><a href="http://rpardz.com/demos/ajax-social-buttons/ajax-social-buttons.zip">Download Source Code &rarr;</a></strong></p>
<h2>How To Guide</h2>
<p><strong>New Improved Code based on feedback in the comments: 30th November 2011</strong></p>
<ol>
<li>Add the following JavaScript code to the HEAD section of your page:
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
$(document).ready(function(){
&nbsp;&nbsp;$('#share').bind('click mouseover', function(){
&nbsp;&nbsp;$('#share').html('&lt;img src="http://www.example.com/ajax-share-loader.gif"&gt;');
&nbsp;&nbsp;$('#share').load("http://www.example.com/social-button-loading.html");
&nbsp;&nbsp;$('#share').unbind('click mouseover');
&nbsp;});
});
&lt;/script&gt;</pre>
</li>
<li>In your page, add a DIV that contains images of the social buttons as follows (this block will be replaced with the live social buttons when the user hovers over the buttons or clicks for touch devices):
<pre>&lt;div id="share"&gt;
&lt;ul&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;img src="http://www.example.com/tweet-share-button.png" alt=""&gt;&amp;nbsp;&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;img src="http://www.example.com/gplus-share-button.png" alt=""&gt;&amp;nbsp;&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;img src="http://www.example.com/linkedin-share-button.png" alt=""&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</pre>
</li>
<li>Finally, create an external file that contains the live social buttons that will replace the above button images. Save the file as <code>social-button-loading.html</code> and save it in the root for your site, I.e. <code>www.example.com/social-button-loading.html</code>. This external file should look as follows:
<pre>&lt;ul&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;script src="http://platform.twitter.com/widgets.js"&gt;&lt;/script&gt;&lt;a href="https://twitter.com/share" class="twitter-share-button" data-count="horizontal"&gt; &lt;/a&gt;&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;script src="https://apis.google.com/js/plusone.js"&gt;&lt;/script&gt;&lt;g:plusone size="medium"&gt;&lt;/g:plusone&gt;&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;script src="http://platform.linkedin.com/in.js"&gt;&lt;/script&gt;&lt;script type="IN/Share" data-counter="right"&gt;&lt;/script&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
</li>
</ol>
<div class="cols cols2">
<div class="col">
<p>I hope you find this useful, and I&#8217;d love to hear what impact this has on page load times for you, so please drop me some feedback in the comments below.</p>
</div>
<div class="col">
<p>Feel free to tweak the code and extend the functionality if you find other uses for it. I&#8217;m keenly interested in how this impacts on load times and overall SEO health for websites, so please share your results.</p>
</div>
</div>
<p><hr />
<a href="http://rpardz.com/blog/load-social-buttons-ajax-jquery/">Load Social Sharing Buttons via Ajax &#038; jQuery</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://rpardz.com/blog/load-social-buttons-ajax-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GZIP Compression Techniques for Better Page Speeds</title>
		<link>http://rpardz.com/blog/gzip-compression-techniques-better-page-speeds/</link>
		<comments>http://rpardz.com/blog/gzip-compression-techniques-better-page-speeds/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 13:25:40 +0000</pubDate>
		<dc:creator>Robin Parduez</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://rpardz.com/blog/?p=1291</guid>
		<description><![CDATA[&#8220;Page speed&#8221; and &#8220;site speed&#8221; have become buzz phrases in the SEO industry since Google started showing site performance data in Webmaster Tools 1 in December 2009. In April 2010 Google stated that site speed would be a part of the ranking algorithm. Although it is worth noting that Matt Cutts reminded webmasters that site [...]<p><hr />
<a href="http://rpardz.com/blog/gzip-compression-techniques-better-page-speeds/">GZIP Compression Techniques for Better Page Speeds</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></description>
			<content:encoded><![CDATA[<div class="cols cols2">
<div class="col">
<p>&ldquo;Page speed&rdquo; and &ldquo;site speed&rdquo; have become buzz phrases in the SEO industry since Google started showing site performance data in Webmaster Tools <sup><a href="http://googlewebmastercentral.blogspot.com/2009/12/how-fast-is-your-site.html">1</a></sup> in December 2009.</p>
<p>In April 2010 Google stated that site speed would be a part of the ranking algorithm. Although it is worth noting that Matt Cutts reminded webmasters that site speed is only a minor ranking factor, and that relevancy is far more important.</p>
<blockquote><p>Like us, our users place a lot of value in speed &#8211; that&#8217;s why we&#8217;ve decided to take site speed into account in our search rankings. <sup><a href="http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html">2</a></sup></p></blockquote>
<p>In 2009, Google performed tests to determine the impact of site page speed on user behaviour. As part of this experiment Google intentionally slowed down the rendering of search engine results pages.</p>
<blockquote><p>Slowing down the search results page by 100 to 400 milliseconds has a measurable impact on the number of searches per user of -0.2% to -0.6%. That&#8217;s 0.2% to 0.6% fewer searches for changes under half a second! <sup><a href="http://googleresearch.blogspot.com/2009/06/speed-matters.html">3</a></sup></p></blockquote>
<p>This therefore raises the question, <strong><em>&ldquo;How important is site page speed as a ranking factor?&rdquo;</em></strong></p>
<h2>How Important is Site Page Speed</h2>
<p>Matt Cutts reminded webmasters that relevancy is more important than page speed, in fact site page speed is a minor ranking factor at this time, and is just one of over 200 signals used in Google&#8217;s ranking algorithm. This could change in future, but page speed should not be seen as a major ranking factor at this time.</p>
<h3>Tools of the Trade</h3>
<p>It is worth noting that there is a lot of opinion on <a href="http://code.google.com/speed/page-speed/">Google&#8217;s Page Speed tool</a> in terms of how useful it is for website owners, and how the information can easily be misinterpreted. The same applies to <a href="http://developer.yahoo.com/yslow/">Yahoo&#8217;s YSlow tool</a>, as some of the recommendations are simply not feasible for smaller website owners. Therefore, I recommend looking at speed data for your site from a variety of sources, and avoid making drastic changes to your site unless you fully understand the implications of such changes.</p>
<ul>
<li><a href="http://tools.pingdom.com/">Pingdom.com</a> &#8211; Free tool, useful graph feature highlighting problems on pages and slow loading scripts</li>
<li><a href="http://loads.in/">Loads.in</a> &#8211; Free tool to test site speed in multiple locations</li>
<li><a href="http://site-perf.com/">Site-Perf.com</a> &#8211; Free tool for testing with specific browsers and other useful options</li>
</ul>
<p>In isolation, the above tools have limited scope, but running your site URLs through a number of tools will highlight any problem pages that are taking too long to render. There are other premium tools such as <a href="http://www.cloudshare.com/">CloudShare</a> for much more detailed testing and monitoring of performance.</p>
<p>The purpose of this article is not to enter the debate as to how good or bad Google’s Page Speed tool is, but rather to provide a robust method for speeding up your website &#8211; whether you choose to use Google Page Speed or not.</p>
</div>
<div class="col">
<p>User-experience is an important consideration that goes beyond simply SEO benefits, especially when considering Google&#8217;s studies on page load time. Therefore, it is good practice to consider site performance as long as page speed improvements are implemented correctly, and never at the expense of providing good-quality, relevant content.</p>
<p><em>The old rule &ldquo;test and test again&rdquo; comes to mind when tweaking your sites performance.</em></p>
<h2>GZIP Content for Improved Page Speed</h2>
<p>I&#8217;ve been experimenting with a number of different techniques to speed up page load time. My aim was to increase rendering time for mobile and tablet devices rather than as a specific SEO consideration. The tweak that had the biggest impact in my experiments was GZIP compression of content. Any small SEO benefit from a fast website is welcome but not a large factor in my experiments, whereas a fast loading site is pleasing to users.</p>
<p>Before implementing any of the following techniques, I recommend running your pages through Google Page Speed, Yahoo YSlow and some of the tools mentioned above, as well as this <a href="http://www.gidnetwork.com/tools/gzip-test.php">GZIP testing tool</a>, (to check whether GZIP is already implemented and give you page size details as shown below). Keep a spreadsheet of performance data to act as a benchmark. This is useful for seeing what changes have an impact on your page load times.</p>
<h3>A Page with no GZIP compression</h3>
<p><a href="http://rpardz.com/blog/wp-content/uploads/2011/09/no-gzip1.jpg" class="img"><img src="http://rpardz.com/blog/wp-content/uploads/2011/09/no-gzip1.jpg" alt="No GZIP Compression" title="No GZIP Compression" width="100%"></a></p>
<h3>A Page with GZIP compression</h3>
<p><a href="http://rpardz.com/blog/wp-content/uploads/2011/09/yes-gzip1.jpg" class="img"><img src="http://rpardz.com/blog/wp-content/uploads/2011/09/yes-gzip1.jpg" alt="GZIP Compression Yes" title="GZIP Compression Yes" width="100%"></a></p>
<p>As you can see in the images above, GZIP compression drastically reduces the size of a page if it is enabled. In the lower image, a reduction of 65% has been achieved.</p>
<p>The following tips will not work for every website, and it is assumed you are using PHP on an Apache server, with the ability to create .htaccess files. It is possible to implement compression on other servers, but this is beyond the scope of this article.</p>
</div>
</div>
<h2>GZIP Content at Server-Level</h2>
<p>If you have access to your server and can add (or edit) an .htaccess file in the root folder (I.e. located here www.example.com/.htaccess), you can simply add the following line of code to GZIP your site content:</p>
<pre>
&lt;IfModule mod_gzip.c&gt;  
&nbsp;&nbsp;mod_gzip_on         Yes  
&nbsp;&nbsp;mod_gzip_dechunk    Yes  
&nbsp;&nbsp;mod_gzip_item_include file      \.(html|htm|css|js|php|xml)$  
&nbsp;&nbsp;mod_gzip_item_include handler   ^cgi-script$  
&nbsp;&nbsp;mod_gzip_item_include mime      ^text\.*  
&nbsp;&nbsp;mod_gzip_item_include mime      ^application/x-javascript.*  
&nbsp;&nbsp;mod_gzip_item_exclude mime      ^image/.*
&lt;/IfModule&gt;
</pre>
</p>
<p>WARNING: Be extremely careful when editing your .htaccess file. <em>Always backup your .htaccess file and be prepared to roll back if your site doesn&#8217;t perform as expected</em>.</p>
<h2>GZIP Content on Shared Hosting Using PHP</h2>
<p>Some shared hosting services don&#8217;t have the GZIP option enabled on the server which means the above technique will have no effect on site performance. If that is the case and you aren&#8217;t seeing improvements in page load times from your earlier benchmarks, there is another method that will work, however it has the disadvantage of being CPU intensive, and is somewhat awkward. However, you may decide to try it on larger external files that you call on every page (I.e. CSS or JavaScript file) initially to see what impact it has on page load times.</p>
<p>There are in fact several ways to implement this method, but I have found the following method to work the best. If you are familiar with using PHP includes, you could automatically call the PHP into your pages.</p>
<p>At the beginning of your pages (must be PHP pages), you add the following code:</p>
<pre>
&lt;?php
&nbsp;&nbsp;ob_start( 'ob_gzhandler' );
?&gt;&lt;!DOCTYPE html&gt;
&lt;html&gt;
...
&lt;/html&gt;
</pre>
</p>
<p>To be more thorough, the above code can be extended to ensure the GZIP module is switched off after use. To do this, you need to add some code to the top and bottom of your pages (this can also apply to JavaScript and CSS files).</p>
<pre>
&lt;?php if(extension_loaded('zlib')) {
&nbsp;&nbsp;ob_start('ob_gzhandler'); }
?&gt;&lt;!DOCTYPE html&gt;
&lt;html&gt;
...
&lt;/html&gt;&lt;?php if(extension_loaded('zlib')) {
&nbsp;&nbsp;ob_end_flush(); }
?&gt;
</pre>
</p>
<p>You can add the above code to external JavaScript and CSS files as well, but you need to change the name of these files as follows (and remember to update your pages to refer to the <code>.css.php</code> and <code>.js.php</code> file extensions):</p>
<ul>
<li>http://www.example.com/css/stylesheet.css.php</li>
<li>http://www.example.com/js/javascript.js.php</li>
</ul>
<p>Below is an example of how this would look for an external CSS file:</p>
<pre>
&lt;?php if(extension_loaded('zlib')) {
&nbsp;&nbsp;ob_start('ob_gzhandler'); } 
?&gt;
body {
&nbsp;&nbsp;font-family:helvetica,arial,sans-serif;
&nbsp;&nbsp;font-size:13px
}
article,aside,figure,footer,header,
hgroup,nav,section {
&nbsp;&nbsp;display:block
}
...
&lt;?php if(extension_loaded('zlib')) {
&nbsp;&nbsp;ob_end_flush(); }
?&gt;
</pre>
</p>
<p>By using one of the above methods you should be able to compress content on your site and benefit from faster page load times, but as mentioned before, thoroughly test any server-level changes that you make, as servers can be setup to behave differently. I have tested the PHP GZIP method in various browsers with no bugs or issues, but again, be sure to perform your own tests on a variety of browsers and on different platforms.</p>
<p><hr />
<a href="http://rpardz.com/blog/gzip-compression-techniques-better-page-speeds/">GZIP Compression Techniques for Better Page Speeds</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://rpardz.com/blog/gzip-compression-techniques-better-page-speeds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SimplePie &amp; jQuery Flickr Photostream</title>
		<link>http://rpardz.com/blog/simplepie-jquery-flickr-photostream/</link>
		<comments>http://rpardz.com/blog/simplepie-jquery-flickr-photostream/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 14:10:29 +0000</pubDate>
		<dc:creator>Robin Parduez</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://rpardz.com/blog/?p=1173</guid>
		<description><![CDATA[If you want to display a number of photos on your website, jQuery Infinite Carousel is a very good option. This carousel works really well when you have a list of images on your page, but it threw up a number of problems when calling images dynamically on page load (I.e. your latest Flickr Photostream). [...]<p><hr />
<a href="http://rpardz.com/blog/simplepie-jquery-flickr-photostream/">SimplePie &amp; jQuery Flickr Photostream</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></description>
			<content:encoded><![CDATA[<div class="cols cols2">
<div class="col first">
<p>If you want to display a number of photos on your website, <a href="http://jqueryfordesigners.com/jquery-infinite-carousel/" rel="external">jQuery Infinite Carousel</a> is a very good option. This carousel works really well when you have a list of images on your page, but it threw up a number of problems when calling images dynamically on page load (I.e. your latest Flickr Photostream).</p>
<p>After making some of my own tweaks, and combining the carousel with SimplePie RSS feed parsing, I&#8217;ve now got a very nice carousel slider that works well across most (modern) browsers.</p>
<p>The following code uses SimplePie to parse the Flickr feed, cache the images into a folder, and then dynamically pull the images into the HTML on page load.</p>
</div>
<div class="col">
<p>I also setup a <a href="http://brightscape.net/blog/cronjob-auto-update-rss-cache/">cronjob</a> to automatically update the cache on a weekly basis (I don&#8217;t update my Flickr account anymore than that).</p>
<p>This fixed the issue with the carousel and sped up page loads because the images are called from a cache folder rather than being downloaded each time from the Flickr API.</p>
<p>It&#8217;s important that the cronjob is in place; otherwise SimplePie will parse the Flickr feed on each load (or however often you set the cache to expire). I covered this in a previous post regarding <a href="http://brightscape.net/blog/simplepie-parse-rss-atom-feeds/">parsing of Google Reader shared items</a>.</p>
<p><img src="http://rpardz.com/blog/wp-content/uploads/2011/09/carousel-image-05-09-2011-300x81.jpg" alt="jQuery Carousel" title="jQuery Carousel" width="300" height="81" class="imgright" /><br />
<a href="http://rpardz.com/about/">See demo here &rarr;</a></p>
</div>
</div>
<h3>How to do it</h3>
<p>1. Download carousel.js from <a href="http://rpardz.com/downloads/carousel.js">here</a> and upload to a folder on your server (I.e. www.example.com/js/carousel.js)</p>
<p>2. Download SimplePie <a href="http://simplepie.org/downloads/?download" rel="external">here</a> and follow the instructions for installing SimplePie on your server.</p>
<p>3. Create a PHP page made up of the following elements (I&#8217;ve commented within the code with some specific instructions) and upload it to your server:</p>
<h4>PHP: Place this code at start of HTML page</h4>
<pre>&lt;?php
// Change the path below to the location of simplepie.inc on your server
require '/home/username/public_html/simplepie.inc';

// Change the URL below to the feed URL for your Flickr Photostream or a specific set
$url = 'http://api.flickr.com/services/feeds/photoset.gne?set=72157621912224879&amp;nsid=39505387@N02&amp;lang=en-us';
$feed = new SimplePie();
$feed-&gt;set_feed_url($url);

// This allows the cronjob to handle image caching rather than slow page loads as SimplePie parses the feed each time
$feed-&gt;set_cache_duration(999999999);
$feed-&gt;set_timeout(-1);

// Change the location below to where you have placed your cache folder and CHMOD the cache folder to 755 or 777
$feed-&gt;set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/folder/cache');
$feed-&gt;init();

$feed-&gt;handle_content_type();

function image_from_description($data) {
  preg_match_all('/&lt;img src="([^"]*)"([^&gt;]*)&gt;/i', $data, $matches);
  return $matches[1][0];
  }

  function select_image($img, $size) {
    $img = explode('/', $img);
    $filename = array_pop($img);

    $s = array(
    '_s.', // square
    '_t.', // thumb
    '_m.', // small
    '.',   // medium
    '_b.'  // large
    );

 $img[] = preg_replace('/(_(s|t|m|b))?\./i', $s[$size], $filename);
 return implode('/', $img);
 }
?&gt;</pre>
<h4>HTML/PHP: The rest of the HTML page looks like this</h4>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  &lt;title&gt;SimplePie and Infinite Carousel Example&lt;/title&gt;
  &lt;script src="http://www.example.com/css/style.css" type="text/css"&gt;&lt;/script&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="http://www.example.com/js/carousel.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){$('.infiniteCarousel').infiniteCarousel();});
  &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;h1&gt;SimplePie and Infinite Carousel Example&lt;/h1&gt;
  &lt;div class="infiniteCarousel"&gt;
  &lt;div id="flickrgallery"&gt;
  &lt;ul&gt;
  &lt;?php foreach ($feed-&gt;get_items() as $item): ?&gt;
  &lt;li&gt;&lt;?php
    if ($enclosure = $item-&gt;get_enclosure()) {
    $img = image_from_description($item-&gt;get_description());

/* Choose image size you want to link to (full_url) and display in carousel (thumb_url)
    $full_url = select_image($img, 3);
    $thumb_url = select_image($img, 0);
      echo '&lt;a href="' . $full_url . '" title="' . $enclosure-&gt;get_title() . '"&gt;&lt;img src="' . $thumb_url . '" alt=" " /&gt;&lt;/a&gt;'."\n";
    }
  ?&gt;&lt;/li&gt;
  &lt;?php endforeach; ?&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h4>CSS: Create an external stylesheet like this</h4>
<pre>.infiniteCarousel {
	width:533px;
	position:relative
}
.infiniteCarousel #flickrgallery {
  /* .infiniteCarousel width - (.wrapper margin-left +
  .wrapper margin-right) */
  width:465px;
  overflow:auto;
  height:110px;
  margin:0 34px;
  position:absolute;
  top:0
}
.infiniteCarousel ul a img {
  border:5px solid #fff;
  -moz-border-radius:5px;
  -webkit-border-radius:5px;
  border-radius:5px
}
.infiniteCarousel #flickrgallery ul {
  width:840px;
  list-style-image:none;
  list-style-position:outside;
  list-style-type:none;
  margin:0;
  padding:0;
  position:absolute;
  top:0
}
.infiniteCarousel ul li {
  display:block;
  float:left;
  padding:0 10px 0 0;
  height:85px;
  width:85px
}
.infiniteCarousel ul li img {
  -moz-transition:border-color 400ms;
  -webkit-transition:border-color 400ms;
  transition:border-color 400ms;
}
.infiniteCarousel ul:hover li img {
  border-color:#fff
}
.infiniteCarousel ul:hover li:hover img {
  border-color:#fff
}
.infiniteCarousel ul li a img {
  display:block
}
.infiniteCarousel .arrowflickr {
  display:block;
  height:85px;
  width:30px;
  /* Add images for forward/back arrows &amp; use negative text-indent 
  to hide arrow characters - uncomment CSS below as necessary */
  /*background:url("http://www.yourwebsite.com/images/arrows.png") no-repeat;
  text-indent:-9999px;*/
  position:absolute;
  top:0;
  cursor:pointer;
  outline:0;
  border:0
}
.infiniteCarousel .forward {
  background-position:-830px -1020px;
  right:0
}
.infiniteCarousel .back {
  background-position:-830px -1128px;
  left:0
}
.infiniteCarousel .forward:hover, 
.infiniteCarousel .back:hover {
  background-color:#fff
}</pre>
<p>4. Create the following cronjob PHP file which will tell SimplePie to parse the feed at the time(s) you specify (<a href="http://brightscape.net/blog/cronjob-auto-update-rss-cache/">For a discussion of cronjob see previous post</a>):</p>
<pre>&lt;?php
	// Change the path below to the location of simplepie.inc on your server
	require '/home/folder/public_html/simplepie.inc';

	// Change the URL below to the feed URL for your Flickr Photostream or a specific set
	$url = 'http://api.flickr.com/services/feeds/photoset.gne?set=72157621912224879&amp;nsid=39505387@N02&amp;lang=en-us';
	$feed = new SimplePie();
	$feed-&gt;set_feed_url($url);

	// Tells SimplePie to update cache every time PHP file is loaded. Cronjob handles specific times that this page is loaded
	$feed-&gt;set_cache_duration(0);
	$feed-&gt;set_timeout(5);

	// Change the location below to where you have placed your cache folder and CHMOD the cache folder to 755 or 777
	$feed-&gt;set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/folder/cache');
	$feed-&gt;init();
	$feed-&gt;handle_content_type();
	function image_from_description($data) {
    preg_match_all('/&lt;img src="([^"]*)"([^&gt;]*)&gt;/i', $data, $matches);
    return $matches[1][0];
	}
	function select_image($img, $size) {
    $img = explode('/', $img);
    $filename = array_pop($img); 
    $s = array(
        '_s.', // square
        '_t.', // thumb
        '_m.', // small
        '.',   // medium
        '_b.'  // large
    );
    $img[] = preg_replace('/(_(s|t|m|b))?\./i', $s[$size], $filename);
    return implode('/', $img);
	}
?&gt;</pre>
<p>5. Upload PHP file to your server and setup a cronjob to automatically load the file at set time(s).</p>
<p><hr />
<a href="http://rpardz.com/blog/simplepie-jquery-flickr-photostream/">SimplePie &amp; jQuery Flickr Photostream</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://rpardz.com/blog/simplepie-jquery-flickr-photostream/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress SEO Tweaks Without Plugins</title>
		<link>http://rpardz.com/blog/wordpress-seo-tweaks-without-plugins/</link>
		<comments>http://rpardz.com/blog/wordpress-seo-tweaks-without-plugins/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 15:00:38 +0000</pubDate>
		<dc:creator>Robin Parduez</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://rpardz.com/blog/?p=1063</guid>
		<description><![CDATA[If possible I like to tweak WordPress installs and avoid adding extraneous plugins. Generally the more plugins you have, the slower your WordPress site loads, and you can have compatibility issues when you upgrade. One area for consideration is duplicate content, and there are a number of excellent plugins available for handling duplicate content issues. [...]<p><hr />
<a href="http://rpardz.com/blog/wordpress-seo-tweaks-without-plugins/">WordPress SEO Tweaks Without Plugins</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></description>
			<content:encoded><![CDATA[<div class="cols2 cols">
<div class="col">
<p>If possible I like to tweak WordPress installs and avoid adding extraneous plugins. Generally the more plugins you have, the slower your WordPress site loads, and you can have compatibility issues when you upgrade.</p>
<p>One area for consideration is duplicate content, and there are a number of excellent plugins available for handling duplicate content issues. <a href="https://wordpress.org/extend/plugins/all-in-one-seo-pack/" rel="external">All in One SEO Pack</a> and <a href="http://yoast.com/wordpress/seo/" rel="external">Joost de Valk&#8217;s WordPress SEO Plugin</a> are very good, however, for my personal requirements both these plugins add a lot of unnecessary functionality.</p>
<p>If you prefer full control over your WordPress source code, by making a few slight tweaks you can handle an SEO duplicate content issue using the Meta Robots tag and have more control over page titles. If you are new to SEO or the Meta Robots tag, you can read more about this element <a href="http://googlewebmastercentral.blogspot.com/2007/03/using-robots-meta-tag.html" rel="external">here</a>.</p>
<p>Basically, I prefer to <code>noindex,follow</code> category (<code>is_archive()</code>), tag (<code>is_tag()</code>), search (<code>is_search()</code>) and pagination pages (<code>is_paged()</code>). This enables search engines to crawl the pages for links which are subsequently followed. Therefore, the blog homepage and individual posts are indexed as normal, but duplicate content issues with category and tag pages are avoided. Also other unnecessary pages that you wouldn&#8217;t want indexed and returned in search results are <code>noindex,follow</code>.</p>
<h2>Meta Robots Tag</h2>
<p>The code for enabling this feature is as follows, and needs to be included in your header.php file which can be found in your WordPress admin panel under <strong>Appearance &gt; Editor &gt; header.php</strong>.</p>
<pre>
&lt;?php if ( is_tag() ) {
    echo "&lt;meta name=\"robots\" content=\"noindex,follow\"&gt;";
    } elseif ( is_archive() ) {
    echo "&lt;meta name=\"robots\" content=\"noindex,follow\"&gt;";
    } elseif ( is_search() ) {
    echo "&lt;meta name=\"robots\" content=\"noindex,follow\"&gt;";
    } elseif ( is_paged() ) {
    echo "&lt;meta name=\"robots\" content=\"noindex,follow\"&gt;";
    } else {
    echo "&lt;meta name=\"robots\" content=\"index,follow\"&gt;";
    }
?&gt;
</pre>
<p>You may choose to tweak the above code to enable indexing of category pages (<code>is_archive()</code>) for example. To do this, you would simply delete the line:</p>
<pre>
elseif ( is_archive() ) {
    echo "&lt;meta name=\"robots\" content=\"noindex,follow\"&gt;";
    }
</pre>
</div>
<div class="col">
<h2>Title Tag</h2>
<p>Another area for consideration is the page title. Again, there are a lot of plugins that make it easy to control titles for different pages. However, if you prefer manual control, you can add the following code to your header.php file which can be found in your WordPress admin panel under <strong>Appearance &gt; Editor &gt; header.php</strong>.</p>
<pre>
&lt;title&gt;
    &lt;?php wp_title(''); ?&gt;&lt;?php if(wp_title('', false)) {
      echo ' | '; } ?&gt;&lt;?php bloginfo('name'); if(is_home()) {
      echo ' | '; bloginfo('description'); }
    ?&gt;
&lt;/title&gt;
</pre>
<p>The above code basically includes the blog homepage title at the beginning of the title tag on the homepage, and includes the description taken from <strong>Settings &gt; General &gt; Tagline</strong>. On individual blog post pages, the post title is included on the left&#8211;hand side of the title tag, and the blog name is moved to the right&#8211;side of the title.</p>
<h3>Title Examples</h3>
<p>Homepage:<br />
<strong>Robin Parduez | Blog | Front-end Development Tips &amp; Ramblings</strong></p>
<p>Blog post:<br />
<strong>WordPress SEO Tweaks Without Plugins | Robin Parduez | Blog</strong></p>
<h3>Disclaimer</h3>
<p><strong>Please test any code changes that you make to your WordPress installation.</strong> Test your blog to ensure the meta robots <code>noindex,follow</code> tag is <strong>only</strong> applied to category, tag, search, pagination pages and <code>index,follow</code> is applied to the blog homepage and individual post pages. Be sure to test your page titles as well, they should follow the pattern shown in the examples above.</p>
<p>There are of course many more features available if you use an SEO plugin, and for some users a plugin will be suitable. You may also wish to tweak the code examples above to meet your needs.</p>
<p>If you have any comments or suggestions please feel free to give some feedback in the comments section below.</p>
</div>
</div>
<p><hr />
<a href="http://rpardz.com/blog/wordpress-seo-tweaks-without-plugins/">WordPress SEO Tweaks Without Plugins</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://rpardz.com/blog/wordpress-seo-tweaks-without-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Squeeze Your CSS Files Into Shape</title>
		<link>http://rpardz.com/blog/squeeze-css-files/</link>
		<comments>http://rpardz.com/blog/squeeze-css-files/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 12:40:39 +0000</pubDate>
		<dc:creator>Robin Parduez</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://rpardz.com/blog/?p=1007</guid>
		<description><![CDATA[Reducing file size without compromising functionality is important for forward-thinking web developers. Many modern CSS-driven websites use huge external CSS files of anything up to about 20-25kb. By using CSS shorthand the overall file size can be reduced, increasing the speed of page loads and decreasing bandwidth usage. Another method is to use a compression [...]<p><hr />
<a href="http://rpardz.com/blog/squeeze-css-files/">Squeeze Your CSS Files Into Shape</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></description>
			<content:encoded><![CDATA[<div class="cols cols2">
<div class="col first">
<p>Reducing file size without compromising functionality is important for forward-thinking web developers. Many modern CSS-driven websites use huge external <acronym title="Cascading Style Sheets">CSS</acronym> files of anything up to about 20-25kb.</p>
<p>By using CSS shorthand the overall file size can be reduced, increasing the speed of page loads and decreasing bandwidth usage. Another method is to use a compression utility to remove white-space, similar to JavaScript compression.</p>
</div>
<div class="col">
<p>A good compression utility is available at <a href="http://www.cleancss.com/?lang=en" rel="external">CleanCSS</a> which has a variety of options to choose. CleanCSS can arrange your code to reduce character usage, thus decreasing the file size. As with any type of compression it is advisable to keep a backup copy of your stylesheet just in case you aren&#8217;t happy with the results.</p>
<p>I have often made simple mistakes that add unnecessary characters to my style sheets. Below are some shorthand ways to reduce the size of your CSS files. It is worth keeping a backup version of your original style sheet just in-case you want to roll back at some point.</p>
</div>
</div>
<div class="cols cols2">
<div class="col first">
<h2>Combine Properties</h2>
<p>If you define your padding as follows:</p>
<pre>padding-top:5px;
padding-bottom:10px;
padding-left:7px;
padding-right:0px</pre>
<p>You can simplify this into one line:</p>
<pre>padding:5px 0 10px 7px</pre>
<p>The rule to remember here is <b>TR</b>ou<b>BL</b>e. Define your styles in this order: Top, Right, Bottom, Left. Also notice the right padding is 0, therefore adding &#8216;px&#8217; or &#8216;em&#8217; is unnecessary.</p>
<p>When you have matching top and bottom or left and right padding. As follows:</p>
<pre>padding-top:12px;
padding-bottom:12px;
padding-right:0px;
padding-left:6px</pre>
<p>This can be shortened to:</p>
<pre>padding:12px 0 6px</pre>
<p>If you have the following situation, you can shorten it as well:</p>
<pre>padding-top:10px;
padding-right:20px;
padding-left:20px;
padding-bottom:10px</pre>
<p>This can be shortened to:</p>
<pre>padding:10px 20px</pre>
<p><i>The above shortening method works for padding and margin.</i></p>
<h2>Shorthand Colours</h2>
<p>If you define your colours using the standard 6 digit code, you can shorten certain colours to 3 digits:</p>
<pre>Black #000000 becomes #000
White #ffffff becomes #fff</pre>
<p>This shorthand also works for more complex colour codes, as long as the 6-digits are made up of triplets that are doubled (web-safe colours as seen <a href="http://www.lynda.com/hex.asp" rel="external">here</a>):</p>
<pre>Green #99ff33 becomes #9f3
Orange #ffcc00 becomes #fc0
Red #ff3300 becomes #f30</pre>
<p>This method or colour shorthand works for all the web-safe colours, and reduces file size.</p>
</div>
<div class="col">
<h2>Combine Elements</h2>
<p>If you have an example similar to the following code, you can further reduce file size by combining elements with the same properties into the same string.</p>
<pre>p {
border:0;
padding:0;
margin:0;
font-size:1.2em;
color:#000
}
.main-text {
border:0;
padding:0;
margin:0;
font-size:1.2em;
color:#360
}
.required {
border:0;
padding:0;
margin:0;
font-size:1em;
color:#ccc
}</pre>
<p>From the above code, some of the elements share the same properties. We can combine these shared elements to save repeating unnecessary code &#8211; and thus saving ourselves some more bytes.</p>
<pre>p,.main-text,.required {
border:0;
padding:0;
margin:0
}
p, .main-text {
font-size:1.2em
}
p {
color:#000
}
.main-text {
color:#360
}
.required {
font-size:1em;
color:#ccc
}</pre>
<p>These are just a few ways to reduce the size of your style sheets.</p>
<p>As mentioned before, there are various online tools that allow you to compress your CSS files if you want to shave even more bytes off your CSS.</p>
</div>
</div>
<p><hr />
<a href="http://rpardz.com/blog/squeeze-css-files/">Squeeze Your CSS Files Into Shape</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://rpardz.com/blog/squeeze-css-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GZIP HTML Content on Shared Hosting</title>
		<link>http://rpardz.com/blog/gzip-html-content-shared-hosting/</link>
		<comments>http://rpardz.com/blog/gzip-html-content-shared-hosting/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 12:45:22 +0000</pubDate>
		<dc:creator>Robin Parduez</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://rpardz.com/blog/?p=983</guid>
		<description><![CDATA[If you host your website on a shared Apache hosting account, it&#8217;s highly unlikely that you will have access to the httpd.conf file to set default GZIP compression for your website files. A quick and simple alternative is to set GZIP compression on each page so that you can effectively compress the HTML output content [...]<p><hr />
<a href="http://rpardz.com/blog/gzip-html-content-shared-hosting/">GZIP HTML Content on Shared Hosting</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></description>
			<content:encoded><![CDATA[<div class="cols cols2">
<div class="col first">
<p>If you host your website on a shared Apache hosting account, it&#8217;s highly unlikely that you will have access to the httpd.conf file to set default GZIP compression for your website files. A quick and simple alternative is to set GZIP compression on each page so that you can effectively compress the HTML output content on page load. <strong>Note: This only works for pages with the .php file extension and only GZIPs the HTML.</strong></p>
<p>The PHP code is placed at the very top of your page, I.e. the very first piece of code to be executed on the page. It is also recommended that the closing PHP tag is on the same line as the HTML doctype for optimal backward compatibility.</p>
<pre>
&lt;?php
   // GZIP Compression
   ob_start( 'ob_gzhandler' );
?&gt;
</pre>
</div>
<div class="col">
<p>The following example shows how to place the PHP GZIP code at the top of your pages. It is always advisable to test this on a non&#8211;important page before rolling out across all pages on your site.</p>
<pre>
&lt;?php
   // GZIP Compression
   ob_start( 'ob_gzhandler' );
?&gt;&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;!-- head content goes here --&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!-- body content goes here --&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</div>
</div>
<p><hr />
<a href="http://rpardz.com/blog/gzip-html-content-shared-hosting/">GZIP HTML Content on Shared Hosting</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://rpardz.com/blog/gzip-html-content-shared-hosting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rewrite URLs on Apache with mod_rewrite</title>
		<link>http://rpardz.com/blog/rewrite-urls-apache-mod-rewrite/</link>
		<comments>http://rpardz.com/blog/rewrite-urls-apache-mod-rewrite/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 13:54:00 +0000</pubDate>
		<dc:creator>Robin Parduez</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://rpardz.com/blog/?p=963</guid>
		<description><![CDATA[Is your website accessible by typing www.yourdomain.com as well as yourdomain.com, well using mod_rewrite on Apache servers you will be able to control how your URL structure is displayed whichever way the user types in your address. Controlling the URL structure is in fact more important than some people realise. I have used mod_rewrite on [...]<p><hr />
<a href="http://rpardz.com/blog/rewrite-urls-apache-mod-rewrite/">Rewrite URLs on Apache with mod_rewrite</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></description>
			<content:encoded><![CDATA[<div class="cols cols2">
<div class="col first">
<p>Is your website accessible by typing www.yourdomain.com as well as yourdomain.com, well using mod_rewrite on Apache servers you will be able to control how your URL structure is displayed whichever way the user types in your address. Controlling the URL structure is in fact more important than some people realise.</p>
<p>I have used mod_rewrite on this website so that if the user types www.brightscape.net, brightscape.net, or blog.brightscape.net (the old blog URL), they see a single uniform URL structure. I chose not to display &#8216;www.&#8217; for my domain. This is personal preference, however I feel the shorter the URL the better. Unnecessary clutter can make your domain name less memorable.</p>
<p>With mod_rewrite on Apache, you still receive all your visitors no matter which of the above URLs they type into the address bar, however, they will see the URL change to your preset structure. Below is an example of how I used mod_rewrite on my own website. I will display examples of how this can be acheived on your own website if it is running on Apache.</p>
<h2>Step by step guide</h2>
<h3>1. Create an .htaccess file</h3>
<p>You first need to create an &#8216;.htaccess&#8217; file that will be placed in your website root folder. To do this open Notepad or another text editor. You simply need to save the empty text file as .htaccess. There should be no other file extention such as .txt, so to do this in Notepad click Save As &gt; Save as type &gt; type in .htaccess &gt; Save. Leave the file open so that we can now add our mod_rewrite code.</p>
<h3>2. Add the mod_rewrite code to .htaccess</h3>
<p>If you want to display your URLs <em>with</em> www. then use the following code:</p>
<pre>RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com$
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]</pre>
</div>
<div class="col">
<p>Copy the above code into your .htaccess file, remembering to change the URL to match your own URL. Save the file and upload it to your root folder. Now test to check that it works correctly. Do this by typing yourdomain.com into the address bar. The URL should change to www.yourdomain.com and load the page. This usually happens in a split second.</p>
<p>If you prefer to display your URL <em>without</em> www. then use the following code:</p>
<pre>RewriteEngine On
RewriteCond %{HTTP_HOST} !^yourdomain.com$ [NC]
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]</pre>
<p>As with the previous example, copy the above code into your .htaccess file, remembering to change the URL to match your own URL. Save the file and upload it to your root folder. Test to check that it works correctly. Do this by typing www.yourdomain.com into the address bar. The URL should change to yourdomain.com and load the page.</p>
<h3>Additional Options</h3>
<p>You can take the above examples further. If you set out your website using a folder structure with index.htm/.html/.php for the file names, then you can make sure that only the folder is displayed like so &#8211; <strong>rpardz.com/about/</strong> rather than <strong>rpardz.com/about/index.php</strong>.</p>
<p>To do this you can add the following code to either of the above examples below the coding you have already used.</p>
<pre>RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|htm|html)\ HTTP
RewriteRule ^(.*)index\.(php|htm|html)$ /$1 [R=301,L]</pre>
<p>This will make sure that the folder structure displays the page properly, but &#8216;index.php&#8217; will not appear in the address bar. You can add additional file extensions by separating them with the pipe symbol | as shown in the above code.</p>
</div>
</div>
<p><hr />
<a href="http://rpardz.com/blog/rewrite-urls-apache-mod-rewrite/">Rewrite URLs on Apache with mod_rewrite</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://rpardz.com/blog/rewrite-urls-apache-mod-rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using PHP Includes for Global Navigation Links</title>
		<link>http://rpardz.com/blog/using-php-includes-global-navigation-links/</link>
		<comments>http://rpardz.com/blog/using-php-includes-global-navigation-links/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 16:30:17 +0000</pubDate>
		<dc:creator>Robin Parduez</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://rpardz.com/blog/?p=948</guid>
		<description><![CDATA[If you look after any large sites you will likely know how frustrating it can be when you need to make even minor changes. This can be something as simple as adding a new page to the global navigation. Traditionally you would need to manually edit every page on the site by adding the relevant [...]<p><hr />
<a href="http://rpardz.com/blog/using-php-includes-global-navigation-links/">Using PHP Includes for Global Navigation Links</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></description>
			<content:encoded><![CDATA[<div class="cols cols2">
<div class="col first">
<p>If you look after any large sites you will likely know how frustrating it can be when you need to make even minor changes. This can be something as simple as adding a new page to the global navigation.</p>
<p>Traditionally you would need to manually edit every page on the site by adding the relevant code to each page, then uploading each page to your server.</p>
</div>
<div class="col">
<p>By using PHP includes you will be able to create a single file which is automatically called on each page on the site automatically server-side. Once you have edited each page and included the PHP include code, you will only ever need to edit one file to make changes across the whole site.</p>
<p>The following tutorial will show you how to create a PHP include file for your global navigation, but the principle applies to any other content that you want to add to every page on your site.</p>
</div>
</div>
<h3 class="toppad">Simple PHP Include File for Global Navigation</h3>
<p>Firstly you will need to create your global navigation in HTML format in a blank text file. Once you have created the file remember to save it with the <code>.php</code> file extension. I generally call it <code>navigation.php</code> as the filename is quite self explanatory.</p>
<pre>
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.example.com/&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.example.com/services/&quot;&gt;Services&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.example.com/blog/&quot;&gt;Blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.example.com/contact/&quot;&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.example.com/about/&quot;&gt;About Us&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>The above code is a very basic example of a global navigation list that would generally be displayed at the top of every page on the site. Below is the HTML with the PHP include file in position. The HTML file below should also be saved with the <code>.php</code> file extension.</p>
<pre>
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;
  &lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;div&gt;
  &lt;!-- Global Navigation --&gt;
  &lt;?php include(&quot;/home/username/public_html/navigation.php&quot;); ?&gt;
  &lt;/div&gt;
  &lt;div&gt;
  &lt;!-- Main Content --&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>From the code above you will see a short line of PHP code inserted into the HTML where the global navigation should be displayed.</p>
<p>On closer inspection the line of PHP code used for the include is as follows:<br />
  <code>&lt;?php include("/home/username/public_html/navigation.php"); ?></code></p>
<p>You will need to specify the absolute path to the PHP file within your server file structure. For a file included globally across the site it is a good idea to include <code>navigation.php</code> within the root folder of your site. The absolute path will vary depending on your webhost and if it throws up error messages you may need to contact your host to request the absolute path for calling a PHP include file.</p>
<p>The above example is a very simple way to implement a PHP include file within your pages. Once you have tested the code above, you can go through the pages on your site and delete your global navigation code and replace it with <code>&lt;?php include("/home/username/public_html/navigation.php"); ?></code>. Now when you need to add or remove pages from the global navigation you simply edit the <code>navigation.php</code> file and upload it to your server. This will now automatically change the content on every page that you have added the PHP include file to.</p>
<h3 class="toppad">More Advanced PHP Include File Options</h3>
<p>The above code shows you the basic principle of using a PHP include file, but what if you want to have an &#8220;on state&#8221; where your link is styled differently when you are on that page, or you want to show an additional link on one page of your site but not on the rest of your site? Both these scenarios can be achieved using PHP.</p>
<h4>Style link for the page you&#8217;re on using PHP &amp; CSS</h4>
<p>To style the link for the current page, you need to give each page a unique title. To do this, you need to define a variable by using the following code at the beginning of each page <code>&lt;?php $currentPage="Home" ?></code>. Each page needs a unique name, so in the above example you need to name the Homepage, Services, Blog, Contact Us and About Us pages.</p>
<p>The only thing left to do is to add some CSS properties to your stylesheet for the class &#8216;on&#8217;. This could be a different colour. In the example page below above I have included CSS within the head section of the page which will style the links to red when the visitor is on that specific page.</p>
<p>The following example shows how to uniquely name each page:</p>
<pre>
&lt;?php
  $currentPage=&quot;Home&quot;;
?&gt;&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;
  &lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;
  &lt;style type=&quot;text/css&quot;&gt;
  .on {
  color:red
  }
  &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;div&gt;
  &lt;!-- Global Navigation --&gt;
  &lt;?php include(&quot;/home/username/public_html/navigation.php&quot;); ?&gt;
  &lt;/div&gt;
  &lt;div&gt;
  &lt;!-- Main Content --&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</p>
<p>Now the <code>navigation.php</code> file needs to be edited so that when the visitor is on the Homepage, a unique class is added to the link for that page. The <code>navigation.php</code> file should be adjusted as follows:</p>
<pre>
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.example.com/&quot; &lt;?php if ($currentPage==&quot;Home&quot;) echo &quot;class=&quot;on&quot;&quot;; ?&gt;&gt;Home&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.example.com/services/&quot; &lt;?php if ($currentPage==&quot;Services&quot;) echo &quot;class=&quot;on&quot;&quot;; ?&gt;&gt;Services&lt;/a&gt;&lt;/li&gt; 
  &lt;li&gt;&lt;a href=&quot;http://www.example.com/blog/&quot; &lt;?php if ($currentPage==&quot;Blog&quot;) echo &quot;class=&quot;on&quot;&quot;; ?&gt;&gt;Blog&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.example.com/contact-us/&quot; &lt;?php if ($currentPage==&quot;Contact Us&quot;) echo &quot;class=&quot;on&quot;&quot;; ?&gt;&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.example.com/about-us/&quot; &lt;?php if ($currentPage==&quot;About Us&quot;) echo &quot;class=&quot;on&quot;&quot;; ?&gt;&gt;About Us&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
</p>
<p>Using the above principles you can take it a step further by replacing the link with &#8216;#&#8217; when the visitor is on a specific page.</p>
<h4>Remove the link on current page</h4>
<p>You will notice in the following example <strong>if</strong> and <strong>else</strong> logic has been used. Edit the <code>navigation.php</code> file as follows:</p>
<pre>
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;&lt;?php if ($currentPage==&quot;Home&quot;) echo &quot;#&quot;; 
       else echo &quot;http://www.example.com/&quot;; ?&gt;&quot; &lt;?php if ($currentPage==&quot;Home&quot;) echo &quot;class=&quot;on&quot;&quot;; ?&gt;&gt;Home&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;&lt;?php if ($currentPage==&quot;Services&quot;) echo &quot;#&quot;; 
       else echo &quot;http://www.example.com/services/&quot;; ?&gt;&quot; &lt;?php if ($currentPage==&quot;Services&quot;) echo &quot;class=&quot;on&quot;&quot;; ?&gt;&gt;Services&lt;/a&gt;&lt;/li&gt; 
  &lt;li&gt;&lt;a href=&quot;&lt;?php if ($currentPage==&quot;Blog&quot;) echo &quot;#&quot;; 
       else echo &quot;http://www.example.com/blog/&quot;; ?&gt;&quot; &lt;?php if ($currentPage==&quot;Blog&quot;) echo &quot;class=&quot;on&quot;&quot;; ?&gt;&gt;Blog&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;&lt;?php if ($currentPage==&quot;Contact Us&quot;) echo &quot;#&quot;; 
       else echo &quot;http://www.example.com/contact-us/&quot;; ?&gt;&quot; &lt;?php if ($currentPage==&quot;Contact Us&quot;) echo &quot;class=&quot;on&quot;&quot;; ?&gt;&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;&lt;?php if ($currentPage==&quot;About Us&quot;) echo &quot;#&quot;; 
       else echo &quot;http://www.example.com/about-us/&quot;; ?&gt;&quot; &lt;?php if ($currentPage==&quot;About Us&quot;) echo &quot;class=&quot;on&quot;&quot;; ?&gt;&gt;About Us&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
</p>
<p>These are just a few basic ways to use PHP includes for global navigation and subsequently defining extra variables. If you have any specific requests please leave a comment and I can create a separate tutorial.</p>
<p><hr />
<a href="http://rpardz.com/blog/using-php-includes-global-navigation-links/">Using PHP Includes for Global Navigation Links</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://rpardz.com/blog/using-php-includes-global-navigation-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Truncate SimplePie Content with PHP</title>
		<link>http://rpardz.com/blog/truncate-simplepie-content-php/</link>
		<comments>http://rpardz.com/blog/truncate-simplepie-content-php/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 12:30:17 +0000</pubDate>
		<dc:creator>Robin Parduez</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://rpardz.com/blog/?p=936</guid>
		<description><![CDATA[This article is a follow-up to an earlier blog post about using SimplePie to display an RSS feed on your website. Sometimes it can be useful to ensure that a piece of content stays on a single line (e.g. a title), or make sure that some text stays to less than 255 characters (e.g. a [...]<p><hr />
<a href="http://rpardz.com/blog/truncate-simplepie-content-php/">Truncate SimplePie Content with PHP</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></description>
			<content:encoded><![CDATA[<div class="cols cols2">
<div class="col first">
<p>This article is a follow-up to an earlier blog post about using <a href="http://brightscape.net/blog/simplepie-parse-rss-atom-feeds/">SimplePie to display an RSS feed</a> on your website.</p>
<p>Sometimes it can be useful to ensure that a piece of content stays on a single line (e.g. a title), or make sure that some text stays to less than 255 characters (e.g. a description) and gets truncated after that point.</p>
<p>My previous blog article showed how to do this with PHP, and I will give a brief recap below. However, the focus of this blog post is to improve truncation of content even further.</p>
<h2 class="toppad">Old Truncation Technique</h2>
<p>The following PHP string truncates or shortens the title to 45 characters and then echo&#8217;s the list of titles parsed from an RSS feed and displays it on the page with ellipses (&#8230;) appended to the end of the title: <code>< ?php echo substr($item->get_title(), 0, 42) . '...'; ?></code></p>
<p>For example: <strong>Here Is a Title That Is 42 Characters long&#8230;</strong> You can see that the title itself is 42 characters long so it hasn&#8217;t been truncated, but the PHP has appended ellipses (&#8230;) to the end of the title. Doing this is quite unnecessary <em>unless</em> the title is over 42 characters.</p>
<h2 class="toppad">Improved Truncation Technique</h2>
<p>The way to deal with this more effectively is to determine the length of the string and then <em>only</em> append the ellipses (&#8230;) if the length of the string exceeds the parameters we have set.</p>
</div>
<div class="col">
<p>This can be done as follows:</p>
<pre>
<?php
  echo substr($item->get_description(), 0, 45);
  $str = $item->get_description();
  if (strlen($str) > 45) echo '...';
?>
</pre>
</p>
<p>To explain the above code line by line, <code>echo substr($item->get_title(), 0, 45);</code>, this line echo&#8217;s or outputs the parsed feed title using SimplePie. The <code>substr</code> function returns the portion of string specified by the start and length parameters. In the above case, 0 represents the first character, and 45 represents the 45th character (spaces are included as characters).</p>
<p>If the title is 45 characters or less, the above code works fine and doesn&#8217;t append the ellipses (&#8230;), which is ideal. However, what if the title is 60 characters in length?</p>
<p>The second line of the above code, <code>$str = $item->get_description();</code> converts the whole title into a string called <code>$str</code>.</p>
<p>The third line of code uses the <code>strlen</code> function, which returns the length of the given string (which we have called <code>$str</code>). By using an <code>if</code> statement in the final line of code <code>if (strlen($str) > 45) echo '...';</code>, we are saying, <em>if</em> the length of the string is greater than 45 characters show the ellipses (&#8230;) otherwise ignore the if statement and <em>don&#8217;t</em> show the ellipses (&#8230;).</p>
<p>It&#8217;s a very simple tweak that can be applied to outputting SimplePie or any other PHP, and it can help to retain a better looking page by avoiding text wrapping.</p>
</div>
</div>
<p><hr />
<a href="http://rpardz.com/blog/truncate-simplepie-content-php/">Truncate SimplePie Content with PHP</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://rpardz.com/blog/truncate-simplepie-content-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compress Pages with MOD_DEFLATE on Apache</title>
		<link>http://rpardz.com/blog/compress-pages-mod-deflate-apache/</link>
		<comments>http://rpardz.com/blog/compress-pages-mod-deflate-apache/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 14:03:54 +0000</pubDate>
		<dc:creator>Robin Parduez</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://rpardz.com/blog/?p=912</guid>
		<description><![CDATA[I have recently been experimenting with mod_deflate on an Apache server to save some bandwidth. If like me, you may have found your host cutting access to your website temporarily if you go over your bandwidth allowance, meaning you have to purchase more bandwidth to get your pages to go &#8216;live&#8217; again. However, by using [...]<p><hr />
<a href="http://rpardz.com/blog/compress-pages-mod-deflate-apache/">Compress Pages with MOD_DEFLATE on Apache</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></description>
			<content:encoded><![CDATA[<div class="cols cols2">
<div class="col first">
<p>I have recently been experimenting with <strong>mod_deflate</strong> on an Apache server to save some bandwidth. If like me, you may have found your host cutting access to your website temporarily if you go over your bandwidth allowance, meaning you have to purchase more bandwidth to get your pages to go &#8216;live&#8217; again.</p>
<p>However, by using gzip or deflate you can shave off valuable bytes/kilobytes each time pages and files are requested from the server. Although the savings may appear to be small, when these savings are multiplied hundreds or thousands of  times over the course of a month it soon highlights the value of using one of these compression techniques.</p>
<p>As I have only tested Apache, this post only relates to Apache compression. Worth noting is that some older browsers don&#8217;t support or have issues with compression. This is not an issue for most of the recent browsers. I have been testing my compression on various browsers including IE5, IE6, IE7, Opera 8 &amp; 9, Safari, Camino &amp; Firefox 1 &amp; 2. I haven&#8217;t come across any problems with any of these browsers. As mod_deflate is easier and quicker to implement I have stuck with this method, however there are some extra options available if you choose to use mod_gzip compression.</p>
<p>I have stuck with compressing HTML, CSS and JavaScript. To do this, the easiest way is to use an .htaccess file in the root of your website. I use the following line of code saved in the .htaccess file:</p>
<pre>AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css</pre>
<p>This line of code can be added to an existing .htaccess file in your root directory if you have already set other parameters.  You can add or remove other file types from the line of code above, but I found it to be adequate for my needs.</p>
</div>
<div class="col">
<p>Once you have implemented compression it is important to test the results. The easiest way is by using FireFox coupled with the <a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="external">Web Developer Tools</a> plug-in.</p>
<p>Once the plug-in is installed follow these steps:</p>
<ol>
<li>Load your website homepage in FireFox</li>
<li>Click tools menu</li>
<li>Navigate to web developer &gt; information &gt; view document size</li>
</ol>
<p>You should then see a page containing information about your website. This page will contain details about any compression that has been carried out on the web page.</p>
<p>It will give a break-down of the individual elements and scripts as well as a total saving. In my case the result showed: <strong>Total 107 KB (138 KB uncompressed)</strong> A saving of 31KB.</p>
<p>It may not sound like much, but can certainly add some zip to the rendering of your pages, and reduce bandwidth bills over the course of a month or year. Further details are available at <a href="http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/" rel="external">betterexplained</a>.</p>
<p>Official <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html" rel="external">Apache Module mod_deflate</a> information.</p>
<p><strong>UPDATE</strong> When testing the compression of my pages, I found that some JS files weren&#8217;t being compressed (Use Web Developers Tool &#8211; Information &gt; View Document Size). If this is the case for you, you can add the following code to your .htaccess file:</p>
<pre>&lt;FilesMatch "\\.(js|css|html|htm|php|xml)$"&gt;
SetOutputFilter DEFLATE
&lt;/FilesMatch></pre>
</div>
</div>
<p><hr />
<a href="http://rpardz.com/blog/compress-pages-mod-deflate-apache/">Compress Pages with MOD_DEFLATE on Apache</a> &#124; Robin Parduez. All Rights Reserved. &copy; 2010 &#8211; 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://rpardz.com/blog/compress-pages-mod-deflate-apache/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

