<?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>iTechLog &#187; Tutorials</title>
	<atom:link href="http://itechlog.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://itechlog.com</link>
	<description>Your source to IT solutions, interesting technology news and code snipets.</description>
	<lastBuildDate>Tue, 10 Jan 2012 17:06:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Create a simple Random Ad widget for your WordPress blog</title>
		<link>http://itechlog.com/wordpress/2010/11/23/creating-a-simple-random-ad-widget-for-your-wordpress-blog/</link>
		<comments>http://itechlog.com/wordpress/2010/11/23/creating-a-simple-random-ad-widget-for-your-wordpress-blog/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 21:54:44 +0000</pubDate>
		<dc:creator>Alex Costa</dc:creator>
				<category><![CDATA[Code Snipets]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://itechlog.com/?p=955</guid>
		<description><![CDATA[<a href="http://itechlog.com/wordpress/2010/11/23/creating-a-simple-random-ad-widget-for-your-wordpress-blog/" title="Create a simple Random Ad widget for your Wordpress blog"></a>Here are the steps for creating a simple Plugin for a Random Ad Widget . This is also a good startup script for those (like me) wanting to learn how to create Plugins and Widgets for WordPress. The idea here &#8230;<p class="read-more"><a href="http://itechlog.com/wordpress/2010/11/23/creating-a-simple-random-ad-widget-for-your-wordpress-blog/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://itechlog.com/wordpress/2010/11/23/creating-a-simple-random-ad-widget-for-your-wordpress-blog/" title="Create a simple Random Ad widget for your Wordpress blog"></a><p>Here are the steps for creating a simple Plugin for a Random Ad Widget . This is also a good startup script for those (like me) wanting to learn how to create Plugins and Widgets for WordPress.</p>
<p>The idea here is to create an Ad delivery widget that will show a random ad on every visited page. Firstly I will show you the whole code, for those who know what they are doing and just want to diss my code and style. Then it will be broken into pieces with detailed explanation for those interested.  If you want to skip it all just <a title="Download .ZIP" href="http://itechlog.com/wp-content/uploads/2010/11/random_ads.zip" target="_blank">download the source code here</a>.</p>
<p>For the sake of this exercise I will call the file random_ads.php but feel free to call it whatever you like. Here we go&#8230;<span id="more-955"></span></p>
<p>This is the code for the plugin currently (Nov/Dec 2010) used on the sidebar of this site, if you refresh this page you should see a different ad appear on the sidebar.<strong><a title="Download .ZIP" href="../wp-content/uploads/2010/11/random_ads.zip" target="_blank"><strong> </strong></a></strong></p>
<div style="padding: 10px; border: 1px solid #000000; background: #eee; font-size: 11px;">&lt;?php <br />
 /* <br />
 Plugin Name: Random Ads <br />
 Version: 0.1 <br />
 Plugin URI:  <br />
 Description: My Random Ads, mainly Think Geek Stuff (by Alex costa) <br />
 Author URI: http://itehchlog.com <br />
 */ <br />
 ?&gt; <br />
 &lt;?php <br />
 function widget_random_ads($args) { <br />
 extract($args);</p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p>echo $before_widget;</p>
<p>$random_deal[] = &#8216;&lt;a href=&#8221;http://www.anrdoezrs.net/click-4163564-10769259&#8243; target=&#8221;_top&#8221;&gt; <br />
 &lt;img src=&#8221;http://www.awltovhc.com/image-4163564-10769259&#8243; width=&#8221;250&#8243; height=&#8221;250&#8243; alt=&#8221;16 Port USB Hub&#8221; border=&#8221;0&#8243;/&gt;&lt;/a&gt;&#8217;;</p>
<p>$random_deal[] = &#8216;&lt;a href=&#8221;http://www.jdoqocy.com/click-4163564-10764658&#8243; target=&#8221;_top&#8221;&gt; <br />
 &lt;img src=&#8221;http://www.lduhtrp.net/image-4163564-10764658&#8243; width=&#8221;250&#8243; height=&#8221;250&#8243; alt=&#8221;ThinkGeek Use Your Brain&#8221; border=&#8221;0&#8243;/&gt;&lt;/a&gt;&#8217;;</p>
<p>srand(time()); <br />
 $sizeof = count($random_deal); <br />
 $random = (rand()%$sizeof); <br />
 print(&#8220;$random_deal[$random]&#8220;);</p>
<p>echo $after_widget;</p>
<p>} <br />
 register_sidebar_widget(&#8216;Random Ads&#8217;,'widget_random_ads&#8217;); <br />
 ?&gt;</p>
</div>
<p><br class="spacer_" /></p>
<p><strong>Let&#8217;s break it down&#8230;</strong></p>
<p><strong>1 &#8211; The plugin header</strong><br />
 Contains all the information about the plugin, this information is shown at the Plugins page in your WordPress admin area.</p>
<p><br class="spacer_" /></p>
<div style="padding: 10px; border: 1px solid #000000; background: #eee; font-size: 11px;">&lt;?php <br />
 /* <br />
 Plugin Name: Random Ads <br />
 Version: 0.1 <br />
 Plugin URI:  <br />
 Description: My Random Ads, mainly Think Geek Stuff (by Alex costa) <br />
 Author URI: http://itehchlog.com <br />
 */ <br />
 ?&gt;</div>
<p><br class="spacer_" /></p>
<p><strong>2 &#8211; the Function &amp; the Widget enclosure</strong></p>
<p>echo $before_widget;   opens the widget</p>
<p>echo $bafter_widget;   closes the widget</p>
<div style="padding: 10px; border: 1px solid #000000; background: #eee; font-size: 11px;">function widget_random_ads($args) { <br />
 extract($args);</p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<p>echo $before_widget; #this opens the widget</p>
<p>$random_deal[] = &#8216;&lt;a href=&#8221;http://www.anrdoezrs.net/click-4163564-10769259&#8243; target=&#8221;_top&#8221;&gt; <br />
 &lt;img src=&#8221;http://www.awltovhc.com/image-4163564-10769259&#8243; width=&#8221;250&#8243; height=&#8221;250&#8243; alt=&#8221;16 Port USB Hub&#8221; border=&#8221;0&#8243;/&gt;&lt;/a&gt;&#8217;;</p>
<p>$random_deal[] = &#8216;&lt;a href=&#8221;http://www.jdoqocy.com/click-4163564-10764658&#8243; target=&#8221;_top&#8221;&gt; <br />
 &lt;img src=&#8221;http://www.lduhtrp.net/image-4163564-10764658&#8243; width=&#8221;250&#8243; height=&#8221;250&#8243; alt=&#8221;ThinkGeek Use Your Brain&#8221; border=&#8221;0&#8243;/&gt;&lt;/a&gt;&#8217;;</p>
<p>srand(time()); <br />
 $sizeof = count($random_deal); <br />
 $random = (rand()%$sizeof); <br />
 print(&#8220;$random_deal[$random]&#8220;);</p>
<p>echo $after_widget; #this closes the widget</p>
<p>}</p>
<p><br class="spacer_" /></p>
</div>
<p><br class="spacer_" /></p>
<p><strong>3 &#8211; The PHP random and variables (where the ads go). </strong></p>
<p>The <strong>$random_deal[]</strong> are the arrays that hold the information to be shown, each array stars with <strong>$random_deal[] =</strong> and the HTML to be output goes inside the single quotation marks<strong> &#8216; &#8216;</strong> and the whole statement ends with semicolons<strong> ;</strong> . Each array contains the HTML a single ad and will be picked at random by the PHP function<strong> rand()</strong> and shown on the page by the command <strong>print().</strong> Note that double quotation marks are allowed inside the single speech marks but if you have a single quotation mark or an apostrophe inside the HTML you must add a slash before it. E.g: alt=&#8221;Today&#8217;s deals&#8221; should be alt=&#8221;today\&#8217;s deals&#8221; .</p>
<p>You can have as many arrays as you want.</p>
<div style="padding: 10px; border: 1px solid #000000; background: #eee; font-size: 11px;">$random_deal[] = &#8216;&lt;a href=&#8221;http://www.anrdoezrs.net/click-4163564-10769259&#8243; target=&#8221;_top&#8221;&gt; <br />
 &lt;img src=&#8221;http://www.awltovhc.com/image-4163564-10769259&#8243; width=&#8221;250&#8243; height=&#8221;250&#8243; alt=&#8221;16 Port USB Hub&#8221; border=&#8221;0&#8243;/&gt;&lt;/a&gt;&#8217;;</p>
<p><br class="spacer_" /></p>
<p>$random_deal[] = &#8216;&lt;a href=&#8221;http://www.jdoqocy.com/click-4163564-10764658&#8243; target=&#8221;_top&#8221;&gt; <br />
 &lt;img src=&#8221;http://www.lduhtrp.net/image-4163564-10764658&#8243; width=&#8221;250&#8243; height=&#8221;250&#8243; alt=&#8221;ThinkGeek Use Your Brain&#8221; border=&#8221;0&#8243;/&gt;&lt;/a&gt;&#8217;;</p>
<p>srand(time()); <br />
 $sizeof = count($random_deal); <br />
 $random = (rand()%$sizeof); <br />
 print(&#8220;$random_deal[$random]&#8220;);</p>
</div>
<p><br class="spacer_" /></p>
<p><strong>4 &#8211; Register the widget.</strong></p>
<p>Now you need to call the widget to be added to WordPress. This is a native WordPress function called register_sidebar_widget(); the argument  <strong>&#8216;Random Ads&#8217;</strong> is the title of the Widget and <strong>&#8216;widget_random_ads&#8217;</strong> is the name of the function above.</p>
<div style="padding: 10px; border: 1px solid #000000; background: #eee; font-size: 11px;">register_sidebar_widget(&#8216;Random Ads&#8217;,'widget_random_ads&#8217;);</div>
<p><br class="spacer_" /></p>
<p><strong>5 &#8211; Installation. </strong></p>
<p>Upload your random_ads.php file to \wp-content\plugins (preferably create a folder called random_ads and put it inside it) via FTP. Then Go to your WordPress plugin administration and activate the plugin.  Now you can drag and drop the widget into your side bar on the Widget admin area under Appearance.</p>
<p style="text-align: center;"><a title="Download .ZIP" href="http://itechlog.com/wp-content/uploads/2010/11/random_ads.zip" target="_blank"><strong>Download random_ads.zip with source code</strong></a></p>

<!-- start wp-tags-to-technorati 1.02 -->

<!-- end wp-tags-to-technorati -->
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>No Related Post</li></ul>]]></content:encoded>
			<wfw:commentRss>http://itechlog.com/wordpress/2010/11/23/creating-a-simple-random-ad-widget-for-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Duplicate Content &amp; Multiple Site Issues</title>
		<link>http://itechlog.com/easy-tips/2009/09/18/google-duplicate-content-multiple-site-issues/</link>
		<comments>http://itechlog.com/easy-tips/2009/09/18/google-duplicate-content-multiple-site-issues/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 11:49:34 +0000</pubDate>
		<dc:creator>Alex Costa</dc:creator>
				<category><![CDATA[Easy Tips]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[crawl]]></category>
		<category><![CDATA[duplicate content]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[redirect 301]]></category>
		<category><![CDATA[rel canonical]]></category>
		<category><![CDATA[search engine]]></category>
		<category><![CDATA[search ranking]]></category>

		<guid isPermaLink="false">http://itechlog.com/easy-tips/2009/09/18/google-duplicate-content-multiple-site-issues/</guid>
		<description><![CDATA[<a href="http://itechlog.com/easy-tips/2009/09/18/google-duplicate-content-multiple-site-issues/" title="Google Duplicate Content &amp; Multiple Site Issues"></a>Great tips on the use of Redirect 301 and rel=canonical among some other good stuff. www.youtube.com/watch?v=6hSoXutuj0g Technorati Tags: crawl, duplicate content, Google, redirect 301, rel canonical, search engine, search ranking Related PostsDecember 11, 2009 -- Microsoft&#8217;s attempt to bribe its &#8230;<p class="read-more"><a href="http://itechlog.com/easy-tips/2009/09/18/google-duplicate-content-multiple-site-issues/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://itechlog.com/easy-tips/2009/09/18/google-duplicate-content-multiple-site-issues/" title="Google Duplicate Content &amp; Multiple Site Issues"></a><p>Great tips on the use of Redirect 301 and rel=canonical among some other good stuff.</p>
<p>
<p><a href="http://www.youtube.com/watch?v=6hSoXutuj0g">www.youtube.com/watch?v=6hSoXutuj0g</a></p></p>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/crawl' rel='tag' target='_self'>crawl</a>, <a class='technorati-link' href='http://technorati.com/tag/duplicate+content' rel='tag' target='_self'>duplicate content</a>, <a class='technorati-link' href='http://technorati.com/tag/Google' rel='tag' target='_self'>Google</a>, <a class='technorati-link' href='http://technorati.com/tag/redirect+301' rel='tag' target='_self'>redirect 301</a>, <a class='technorati-link' href='http://technorati.com/tag/rel+canonical' rel='tag' target='_self'>rel canonical</a>, <a class='technorati-link' href='http://technorati.com/tag/search+engine' rel='tag' target='_self'>search engine</a>, <a class='technorati-link' href='http://technorati.com/tag/search+ranking' rel='tag' target='_self'>search ranking</a></p>

<!-- end wp-tags-to-technorati -->
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>December 11, 2009 -- <a href="http://itechlog.com/itechlog-news/2009/12/11/microsofts-attempt-to-bribe-its-way-to-the-top/" title="Microsoft&#8217;s attempt to bribe its way to the top">Microsoft&#8217;s attempt to bribe its way to the top</a></li><li>January 10, 2012 -- <a href="http://itechlog.com/social-networking/2012/01/10/google-search-goes-social/" title="Google search goes social">Google search goes social</a></li><li>August 1, 2011 -- <a href="http://itechlog.com/itechlog-news/2011/08/01/chrome-overtakes-firefox-uk-number-two-browser-spot-in-july/" title="Chrome Overtakes Firefox for UK Number Two Browser Spot in July">Chrome Overtakes Firefox for UK Number Two Browser Spot in July</a></li><li>July 22, 2011 -- <a href="http://itechlog.com/social-networking/2011/07/22/google-useful-info/" title="Google+ useful info">Google+ useful info</a></li><li>April 1, 2011 -- <a href="http://itechlog.com/itechfeed/2011/04/01/facebook-acquires-bing/" title="Facebook acquires Bing">Facebook acquires Bing</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://itechlog.com/easy-tips/2009/09/18/google-duplicate-content-multiple-site-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GIMP Tutorial and book</title>
		<link>http://itechlog.com/web-design/2009/05/20/gimp-tutorial-and-book/</link>
		<comments>http://itechlog.com/web-design/2009/05/20/gimp-tutorial-and-book/#comments</comments>
		<pubDate>Wed, 20 May 2009 20:29:12 +0000</pubDate>
		<dc:creator>Alex Costa</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[GIMP]]></category>
		<category><![CDATA[GNU]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://itechlog.com/web-design/2009/05/20/gimp-tutorial-and-book/</guid>
		<description><![CDATA[<a href="http://itechlog.com/web-design/2009/05/20/gimp-tutorial-and-book/" title="GIMP Tutorial and book"></a>GIMP is the GNU Image Manipulation Program. It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. GIMP is a versatile graphics manipulation package and it works on Linux, Windows, Mac, &#8230;<p class="read-more"><a href="http://itechlog.com/web-design/2009/05/20/gimp-tutorial-and-book/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://itechlog.com/web-design/2009/05/20/gimp-tutorial-and-book/" title="GIMP Tutorial and book"></a><p><img style="max-width: 800px; float: left; margin-top: 10px; margin-bottom: 10px; margin-right: 10px;" src="http://itechlog.com/wp-content/uploads/2009/05/paint-brush.jpg" alt="" width="116" height="174" /> <a href="http://www.gimp.org" target="_blank">GIMP is the GNU Image Manipulation Program</a>. It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. GIMP is a versatile graphics manipulation package and it works on Linux, Windows, Mac, OpenSolaris and FreeBSD. It is also available in many languages. The official GIMP Project website has a very good <a href="http://www.gimp.org/tutorials/" target="_blank">set of tutorials</a> divided into the following levels:  Beginner, Intermediate, Expert, Photo Editing, Web and Script Authoring.</p>
<p><strong></strong>If you prefer to take your reading away from the screen here are some book that can teach you a lot about this great image manipulation program.</p>
<p><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" id="Player_64f81f74-8868-463c-8a75-6d27dc385312"  WIDTH="600px" HEIGHT="200px"><param NAME="movie" VALUE="http://ws.amazon.co.uk/widgets/q?ServiceVersion=20070822&#038;MarketPlace=GB&#038;ID=V20070822%2FGB%2Fcostafamily-21%2F8010%2F64f81f74-8868-463c-8a75-6d27dc385312&#038;Operation=GetDisplayTemplate"></param><param NAME="quality" VALUE="high"></param><param NAME="bgcolor" VALUE="#FFFFFF"></param><param NAME="allowscriptaccess" VALUE="always"><embed src="http://ws.amazon.co.uk/widgets/q?ServiceVersion=20070822&#038;MarketPlace=GB&#038;ID=V20070822%2FGB%2Fcostafamily-21%2F8010%2F64f81f74-8868-463c-8a75-6d27dc385312&#038;Operation=GetDisplayTemplate" id="Player_64f81f74-8868-463c-8a75-6d27dc385312" quality="high" bgcolor="#ffffff" name="Player_64f81f74-8868-463c-8a75-6d27dc385312" allowscriptaccess="always"  type="application/x-shockwave-flash" align="middle" height="200px" width="600px"></embed></param></object> <noscript><a HREF="http://ws.amazon.co.uk/widgets/q?ServiceVersion=20070822&#038;MarketPlace=GB&#038;ID=V20070822%2FGB%2Fcostafamily-21%2F8010%2F64f81f74-8868-463c-8a75-6d27dc385312&#038;Operation=NoScript">Amazon.co.uk Widgets</a></noscript></p>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/Books' rel='tag' target='_self'>Books</a>, <a class='technorati-link' href='http://technorati.com/tag/GIMP' rel='tag' target='_self'>GIMP</a>, <a class='technorati-link' href='http://technorati.com/tag/GNU' rel='tag' target='_self'>GNU</a>, <a class='technorati-link' href='http://technorati.com/tag/OpenSource' rel='tag' target='_self'>OpenSource</a>, <a class='technorati-link' href='http://technorati.com/tag/Tutorials' rel='tag' target='_self'>Tutorials</a></p>

<!-- end wp-tags-to-technorati -->
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>August 10, 2011 -- <a href="http://itechlog.com/code-snipets/2011/08/10/cardsave-error-transaction-datetime-expired/" title="Cardsave error &#8220;transaction date/time expired&#8221;">Cardsave error &#8220;transaction date/time expired&#8221;</a></li><li>March 26, 2010 -- <a href="http://itechlog.com/itechlog-news/2010/03/26/books-for-sale-linux-shell-qmail-handbook-and-ssltls/" title="Books for sale &#8211; Linux Shell, Qmail Handbook and SSL/TLS">Books for sale &#8211; Linux Shell, Qmail Handbook and SSL/TLS</a></li><li>September 18, 2009 -- <a href="http://itechlog.com/easy-tips/2009/09/18/open-eps-files-on-gimp-for-windows/" title="Open .eps files on GIMP for Windows">Open .eps files on GIMP for Windows</a></li><li>January 14, 2009 -- <a href="http://itechlog.com/open-source/2009/01/14/openoffice-is-sick/" title="OpenOffice is sick">OpenOffice is sick</a></li><li>December 4, 2008 -- <a href="http://itechlog.com/web-programming/2008/12/04/search-engine-optimization-seo-in-php-book/" title="Search Engine Optimization  SEO in PHP (Book)">Search Engine Optimization  SEO in PHP (Book)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://itechlog.com/web-design/2009/05/20/gimp-tutorial-and-book/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

