<?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>Rools Magic Touch</title>
	<atom:link href="http://www.roolsmagictouch.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.roolsmagictouch.com</link>
	<description>Sometimes a little magic is required</description>
	<lastBuildDate>Sun, 25 Sep 2011 08:32:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Dalaipsum, the Dalai Lama lorem ipsum Generator</title>
		<link>http://www.roolsmagictouch.com/2011/dalaipsum-dalai-lama-lorem-ipsum-generator/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dalaipsum-dalai-lama-lorem-ipsum-generator</link>
		<comments>http://www.roolsmagictouch.com/2011/dalaipsum-dalai-lama-lorem-ipsum-generator/#comments</comments>
		<pubDate>Sun, 25 Sep 2011 08:31:50 +0000</pubDate>
		<dc:creator>Rool</dc:creator>
				<category><![CDATA[Showcase]]></category>
		<category><![CDATA[Idea]]></category>

		<guid isPermaLink="false">http://www.roolsmagictouch.com/?p=42</guid>
		<description><![CDATA[Last week I came across the Samuel L. Ipsum Generator, a cool alternative for all those lorem ipsum generators. A few minutes later I got a facebook update with a great quote from the Dalai Lama. That sparked an idea, let&#8217;s combine those two: Dalaipsum, the Dalai Lama lorem ipsum quote generator. With my humble [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I came across the <a href="http://slipsum.com">Samuel L. Ipsum Generator</a>, a cool alternative for all those lorem ipsum generators. A few minutes later I got a facebook update with a great quote from the Dalai Lama. That sparked an idea, let&#8217;s combine those two: Dalaipsum, the Dalai Lama lorem ipsum quote generator.<span id="more-42"></span></p>
<p>With my humble design skills I created <a title="the Dalai Lama lorem ipsum Generator" href="http://dalaipsum.com">dalaipsum.com</a> :<a href="http://www.roolsmagictouch.com/wp-content/uploads/2011/09/screenshot.png"><img class="aligncenter size-full wp-image-43" title="screenshot" src="http://www.roolsmagictouch.com/wp-content/uploads/2011/09/screenshot.png" alt="" width="600" height="400" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.roolsmagictouch.com/2011/dalaipsum-dalai-lama-lorem-ipsum-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto extend WordPress with Custom Fields</title>
		<link>http://www.roolsmagictouch.com/2011/howto-extend-wordpress-custom-fields/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=howto-extend-wordpress-custom-fields</link>
		<comments>http://www.roolsmagictouch.com/2011/howto-extend-wordpress-custom-fields/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 08:00:41 +0000</pubDate>
		<dc:creator>Rool</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.roolsmagictouch.com/?p=35</guid>
		<description><![CDATA[For a recent project I had to build a custom footer for every post and page of a WordPress Site. The easiest solution I could come up involved some custom fields. In order to solve this problem I created three custom fields, style, content left and content right. Entering the values for these is very [...]]]></description>
			<content:encoded><![CDATA[<p>For a recent project I had to build a custom footer for every post and page of a WordPress Site. The easiest solution I could come up involved some custom fields.</p>
<p><a href="http://www.roolsmagictouch.com/wp-content/uploads/2011/09/Shipment-management-Shipitsmarter.png"><img class="aligncenter size-full wp-image-36" title="Shipment management   Shipitsmarter" src="http://www.roolsmagictouch.com/wp-content/uploads/2011/09/Shipment-management-Shipitsmarter.png" alt="" width="739" height="99" /></a>In order to solve this problem I created three custom fields, style, content left and content right. Entering the values for these is very simple in WordPress, the entry form is just below the main rich text editor. If they are missing in your version, be sure to check the Screen Options in the right upper corner.</p>
<p><a href="http://www.roolsmagictouch.com/wp-content/uploads/2011/09/RMT-Custom-Fields.png"><img class="aligncenter size-full wp-image-37" title="RMT - Custom Fields" src="http://www.roolsmagictouch.com/wp-content/uploads/2011/09/RMT-Custom-Fields.png" alt="" width="762" height="276" /></a>I&#8217;ve extended the footer template to use those new custom fields:</p>
<pre class="brush: php; title: ; notranslate">
&lt;footer id=&quot;colophon&quot; role=&quot;contentinfo&quot; class=&quot;&lt;?php echo get_post_meta(get_the_ID(), 'style', true);?&gt;&quot;&gt;
	&lt;div class=&quot;secondary&quot;&gt;
		&lt;p&gt;&lt;?php echo get_post_meta(get_the_ID(), 'left content', true);?&gt;&lt;p&gt;
	&lt;/div&gt;
	&lt;div class=&quot;primary&quot;&gt;
		&lt;div class=&quot;footer-content&quot;&gt;
			&lt;?php echo get_post_meta(get_the_ID(), 'right content', true);?&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div id=&quot;site-generator&quot;&gt;
		......
&lt;/footer&gt;&lt;!-- #colophon --&gt;
</pre>
<p>As you can see from this code, the way to display a custom field is by &lt;?php echo get_post_meta(get_the_ID(), &#8216;Field Name&#8217;, true);?&gt;, where Field Name is the name you entered for your field.</p>
<p>Finally I changed the CSS and added the following lines:</p>
<pre class="brush: css; title: ; notranslate">
footer.red .secondary{
	background-color: #e60000;
}
footer.red .primary h3{
	color: #e60000;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.roolsmagictouch.com/2011/howto-extend-wordpress-custom-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Mailchimp with CodeIgniter</title>
		<link>http://www.roolsmagictouch.com/2011/using-mailchimp-with-codeigniter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-mailchimp-with-codeigniter</link>
		<comments>http://www.roolsmagictouch.com/2011/using-mailchimp-with-codeigniter/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 21:56:26 +0000</pubDate>
		<dc:creator>Rool</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[MailChimp]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.roolsmagictouch.com/?p=12</guid>
		<description><![CDATA[On my new everythingyouliked.com site I wanted to include a MailChimp subscription form. Here&#8217;s the breakdown of how I did this. First of all I&#8217;ve used the excellent CodeIgniter Library for MailChimp API v1.3 from Wayn Hall. I&#8217;ve placed the MCAPI.php into the application/libraries folder and renamed it to Mcapi.php, and renamed the class itself to [...]]]></description>
			<content:encoded><![CDATA[<p>On my new <a href="http://everythingyouliked.com" target="_blank">everythingyouliked.com</a> site I wanted to include a MailChimp subscription form. Here&#8217;s the breakdown of how I did this.</p>
<p>First of all I&#8217;ve used the excellent <a href="https://github.com/waynhall/CodeIgniter-Library-for-MailChimp-API-v1.3" target="_blank">CodeIgniter Library for MailChimp API v1.3</a> from Wayn Hall. I&#8217;ve placed the MCAPI.php into the application/libraries folder and renamed it to Mcapi.php, and renamed the class itself to Mcapi:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
class Mcapi{</pre>
<p>On the MailChimp site I&#8217;ve collected my API Key (Account, Extras, API Keys &amp; Authorized apps) and after creating a new mailinglist I got the list id (Lists, settings, list settings and unique id. Since these are config values, I stored them in my site&#8217;s config file in application/config/my_site.php</p>
<pre class="brush: php; title: ; notranslate">
/*
* MailChimp Settings
*/
$config['mailchimp_key'] = 'xxxxxxxxxxxxxxxxxxxxxxx-us2';
$config['mailchimp_list_id'] = 'yyyyyyyyy';
</pre>
<p>My config file is autoloaded through application/config/autoload.php:</p>
<pre class="brush: php; title: ; notranslate">
$autoload['config'] = array('my_site');
</pre>
<p>In my controller I&#8217;ve added a private function to handle the subscription calls</p>
<pre class="brush: php; title: ; notranslate">
/**
* Handle subscription
* @return string
*/
private function _subscribe(){
	$success = true;
	if(!$this-&gt;input-&gt;get('firstname')){
		$message =  &quot;No firstname provided&quot;;
		$success = false;
	}
	if($success &amp;&amp; !$this-&gt;input-&gt;get('lastname')){
		$message =  &quot;No lastname provided&quot;;
		$success = false;
	}
	if($success &amp;&amp; !$this-&gt;input-&gt;get('emailaddress')){
		$message =  &quot;No email address provided&quot;;
		$success = false;
	}
	if ($success){
		$this-&gt;load-&gt;library('Mcapi', array(
			'apikey' =&gt; $this-&gt;config-&gt;item('mailchimp_key')
		));
		if ($this-&gt;mcapi-&gt;listSubscribe($this-&gt;config-&gt;item('mailchimp_list_id'), $this-&gt;input-&gt;get('emailaddress'), array(
			'FNAME' =&gt; $this-&gt;input-&gt;get('firstname'),
			'LNAME' =&gt; $this-&gt;input-&gt;get('lastname')
		)) === true){
			//	It worked!
			$message = 'Success! Check your email to confirm sign up.';
		} else {
			$success = false;
			//	An error ocurred, return error message
			$message =  'Error: ' . $this-&gt;mcapi-&gt;errorMessage;
		}
	}
	return array('message' =&gt; $message, 'success' =&gt; $success);
}
</pre>
<p>The actual controller function itself is :</p>
<pre class="brush: php; title: ; notranslate">
/**
 * @var dataStorage
 */
private $data;
/**
 * Handle incoming request for /soon/
 * Enter description here ...
 */
public function index()	{
	if ($this-&gt;input-&gt;is_ajax_request()){
		$result = $this-&gt;_subscribe();
		echo json_encode($result);
		exit;
	}
	$this-&gt;load-&gt;view('soon', $this-&gt;data);
}
</pre>
<p>The view contains just a HTML5 form. There are a lot of small neat little tricks you can do in HTML5 forms with placeholders and required flags. Automatic validation for email fields is done by type=&#8221;email&#8221; and is done serverside by MailChimp as well. So I skipped the regex validation of the incoming email address in the controller _subscribe() function.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;aside&gt;
	&lt;form method=&quot;post&quot; id=&quot;keepmeposted&quot; action=&quot;/soon&quot; &gt;
		&lt;fieldset&gt;
			&lt;legend class=&quot;hidden&quot;&gt;keepmeposted&lt;/legend&gt;
			&lt;label for=&quot;firstname&quot;&gt;First name&lt;/label&gt;
			&lt;input name=&quot;firstname&quot; id=&quot;firstname&quot; placeholder=&quot;First name&quot; required&gt;
			&lt;label for=&quot;lastname&quot;&gt;Last name&lt;/label&gt;
			&lt;input name=&quot;lastname&quot; id=&quot;lastname&quot; placeholder=&quot;Last name&quot; required&gt;
			&lt;label for=&quot;emailaddress&quot;&gt;email&lt;/label&gt;
			&lt;input id=&quot;emailaddress&quot; type=&quot;email&quot; name=&quot;emailaddress&quot; placeholder=&quot;me@everythingyouliked.com&quot; required&gt;
			&lt;button&gt;Keep me posted!&lt;/button&gt;
		&lt;/fieldset&gt;
	&lt;/form&gt;
	&lt;p id=&quot;response&quot;&gt;
		&lt;img src=&quot;/images/yes.png&quot; alt=&quot;yes&quot;&gt;Yes, we will keep you updated when we will go live!&lt;br&gt;
		&lt;img src=&quot;/images/no.png&quot; alt=&quot;no&quot;&gt;No, we won't spam or sell your email address.
	&lt;/p&gt;
&lt;/aside&gt;
</pre>
<p>The form submit is handled by a small JQuery script:</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function() {
	$('#keepmeposted').submit(function() {
		$('#response').html('submitting your email....');
		$.getJSON('ajax/soon/', {
				'emailaddress':$('#emailaddress').val(),
				'firstname':$('#firstname').val(),
				'lastname':$('#lastname').val(),
			}, function(data){
			if (data.success == true){
				$(&quot;input&quot;).val('');
			}
			$('#response').html(data.message);
		});
		return false;
	});
});
</pre>
<h2>What does it al do?</h2>
<p>Whenever you submit the form, jquery will do an ajax call to our controller and will get a response JSON object in return containing two values, a boolean value for success and a string value as message. On success I clear out the form with $(&#8220;input&#8221;).val(&#8221;); and always replace the &lt;p id=&#8221;response&#8221;&gt; with the result from the ajax call.</p>
<h2>What I haven&#8217;t done!</h2>
<p>I left out the normal form handling for non javascript calls. I also didn&#8217;t use the <a href="http://codeigniter.com/user_guide/libraries/form_validation.html" target="_blank">standard form validation</a> required when handling non-javascript submits.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.roolsmagictouch.com/2011/using-mailchimp-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

