<?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>Christopher Imrie.com</title>
	<atom:link href="http://www.christopherimrie.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christopherimrie.com</link>
	<description>Tips from the freelance web development world</description>
	<lastBuildDate>Sun, 24 Jan 2010 19:26:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Absolut Pears Bank Holiday Poster</title>
		<link>http://www.christopherimrie.com/2010/01/21/absolut-bank-holiday-poster/</link>
		<comments>http://www.christopherimrie.com/2010/01/21/absolut-bank-holiday-poster/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 17:28:47 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Graphic Design]]></category>
		<category><![CDATA[absolut]]></category>
		<category><![CDATA[bank holiday]]></category>
		<category><![CDATA[mosaic]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[poster]]></category>

		<guid isPermaLink="false">http://www.christopherimrie.com/?p=140</guid>
		<description><![CDATA[I mentioned in my previous post that I came across a whole load of artowork that I produced during my bar days.  I used to manage a club in Bath and I ended up producing all of the flyers and posters for events over the course of the year I was there.
Here is poster I [...]]]></description>
			<content:encoded><![CDATA[<p>I mentioned in my previous post that I came across a whole load of artowork that I produced during my bar days.  I used to manage a club in Bath and I ended up producing all of the flyers and posters for events over the course of the year I was there.</p>
<p>Here is poster I produced for a bank holiday launch party we held for the (at the time) new Absolut Pears vodka.  The idea was to make up the bottle from a mosaic of photos taken of people in the nightclub I worked in.</p>
<p><span id="more-140"></span>The poster was printed quite large (2.5m x 3m) and then placed at the entrance to the club.  Because of the stupendous resolution this poster was produced and printed at, the clientele were then encouraged to find themselves within the bottle.</p>
<p>Beneath the main image is a zoomed in crop section to show the photos.</p>
<p style="text-align: center;"><a href="http://www.christopherimrie.com/wp-content/uploads/2010/01/absolut-mosaic.jpg"><img class="size-full wp-image-141 aligncenter" title="Absolut Pears Poster by Christopher Imrie" src="http://www.christopherimrie.com/wp-content/uploads/2010/01/absolut-mosaic.jpg" alt="Absolut Bank Holiday" width="620" height="930" /></a></p>
<p style="text-align: center;">
<p><a href="http://www.christopherimrie.com/wp-content/uploads/2010/01/absolut-mosaic-small.jpg"><img class="aligncenter size-full wp-image-142" title="absolut-mosaic-small" src="http://www.christopherimrie.com/wp-content/uploads/2010/01/absolut-mosaic-small.jpg" alt="" width="620" height="620" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherimrie.com/2010/01/21/absolut-bank-holiday-poster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New year casino night poster</title>
		<link>http://www.christopherimrie.com/2010/01/21/new-year-casino-night-poster/</link>
		<comments>http://www.christopherimrie.com/2010/01/21/new-year-casino-night-poster/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 01:09:38 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Graphic Design]]></category>
		<category><![CDATA[casino]]></category>
		<category><![CDATA[new year]]></category>
		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://www.christopherimrie.com/?p=128</guid>
		<description><![CDATA[So I have been a web developer for a few years now, and I consider myself very good at what I do.  Even though I tend to spend much of my time in front of a code editor these days, I am fully aware that a big reason for me being good at what [...]]]></description>
			<content:encoded><![CDATA[<p>So I have been a web developer for a few years now, and I consider myself very good at what I do.  Even though I tend to spend much of my time in front of a code editor these days, I am fully aware that a big reason for me being good at what I do is due to my time doing graphic design.</p>
<p>Even though I&#8217;ve been using photoshop for many years (since I was about 15), I only really knew enough to tinker with it.  I had nowhere near enough knowledge about the program to use it for practical project.</p>
<p><span id="more-128"></span>After I finished studying at University for my Aerospace Engineering degree, I decided to take a year out to raise a bit of cash to figure out what to do next.  Naturally a bar job followed (luckily as a Bar Manager, not pint pourer) at a nightclub, where I worked for a couple of weeks shy of a full year.</p>
<p>During my time working there at  I began digging out my Photoshop skills since we needed flyers and event posters made and I refused to pay out for a graphic designer.  Part of this was due to arrogance on my part in thinking I could do just as well as them, but also I really enjoyed graphic designing.</p>
<p>Looking back now I cringe at some of the designs I produced when I first started out, but as the year went on I started to produce better and better work as I got more and more experienced.  Not only did my design skills improve, but so did my knowledge of photoshop.  Another benefit of having worked in an environment producing flyers and posters for a nightclub is that <strong>you learn a lot about paper</strong>.  To this day, the majority of my practical knowledge about the printing process and the various paper &amp; finish options were learnt whilst cranking out flyers and poster.</p>
<p>So whilst going through some old files the other day I came across this gem of a poster I had produced for the nightclub.  I got a call from the nightclub I used to manage, asking me to produce a poster for an upcoming New Years party.  The theme was a James Bond casino night and the poster had to translate this.</p>
<p>Below is what I came up with. Hope you enjoy.</p>
<p><a title="New Year BlueRooms by Christopher Imrie, on Flickr" href="http://www.flickr.com/photos/christopherimrie/4291204159/"><img src="http://farm5.static.flickr.com/4004/4291204159_58abc2b2f0_b.jpg" alt="New Year BlueRooms" width="620" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherimrie.com/2010/01/21/new-year-casino-night-poster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The making of VMCG.co.uk. A video time lapse of converting a JPG to HTML &amp; CSS</title>
		<link>http://www.christopherimrie.com/2010/01/18/the-making-of-vmcg-a-video-time-lapse-of-converting-a-jpg-to-html-css/</link>
		<comments>http://www.christopherimrie.com/2010/01/18/the-making-of-vmcg-a-video-time-lapse-of-converting-a-jpg-to-html-css/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 02:53:33 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[dreamweaver]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[timelapse]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.christopherimrie.com/?p=111</guid>
		<description><![CDATA[I&#8217;ve got a nice treat for anyone who is curious about development process of creating an HTML page from a photoshop mockup.  Attached is a video time lapse of a recent project I completed (the website for Viper Marketing &#38; Communications Group).
The video follows my development process of taking a flat jpg (original mockup was [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a nice treat for anyone who is curious about development process of creating an HTML page from a photoshop mockup.  Attached is a video time lapse of a recent project I completed (the website for <a href="http://www.vmcg.co.uk">Viper Marketing &amp; Communications Group</a>).</p>
<p>The video follows my development process of taking a flat jpg (original mockup was in Fireworks, hence no .psd) and converting it to a pixel perfect HTML &amp; CSS page that is fully valid and accessible.  The development time for this first html page of the project took around five and a half hours, but I&#8217;ve condensed the video down to 30 mins.</p>
<p><span id="more-111"></span></p>
<p>Hope you all enjoy. <br/><br/><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="390" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://blip.tv/play/AYG%2BoWQA" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="390" src="http://blip.tv/play/AYG%2BoWQA" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherimrie.com/2010/01/18/the-making-of-vmcg-a-video-time-lapse-of-converting-a-jpg-to-html-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending ExpressionEngine 2.0 templates through the Communicate panel</title>
		<link>http://www.christopherimrie.com/2010/01/17/sending-expressionengine-2-0-templates-through-the-communicate-panel/</link>
		<comments>http://www.christopherimrie.com/2010/01/17/sending-expressionengine-2-0-templates-through-the-communicate-panel/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 02:15:43 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[expressionengine]]></category>
		<category><![CDATA[communicate]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.christopherimrie.com/?p=101</guid>
		<description><![CDATA[So one of the most frustrating things I always found about ExpressionEngine is Communicate panel.  Now dont get me wrong, I think the communicate panel does exactly what it should do in a very clear and functional manner.  The frustration comes from not being able to use the greatest thing about ExpressionEngine: the templates.
Now I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>So one of the most frustrating things I always found about ExpressionEngine is Communicate panel.  Now dont get me wrong, I think the communicate panel does exactly what it should do in a very clear and functional manner.  The frustration comes from not being able to use the greatest thing about ExpressionEngine: the templates.</p>
<p>Now I&#8217;m not suggesting that EllisLab have got it wrong by not allowing the templates to be used in the Communicate panel, but for some of my projects I like to at least have the option.  Using the templates allows you to really get some nice looking emails stacked with all your site&#8217;s content.</p>
<p><span id="more-101"></span>So to remedy my frustration I came up with a method of adding a drop down list to the ExpressionEngine 2.0 communicate panel that lists your sites templates by template group. You can send plain emails as normal but selecting a template from the list will fill the message text area with the rendered template. Since the template is fully rendered, you can send this very easily to your mailing lists and the unsubscribe links will be appended to the bottom of the email automatically.</p>
<p>Here is a screenshot:</p>
<p><a href="http://www.christopherimrie.com/wp-content/uploads/2010/01/communicate.jpg"><img class="aligncenter size-full wp-image-102" title="communicate" src="http://www.christopherimrie.com/wp-content/uploads/2010/01/communicate.jpg" alt="" width="620" height="443" /></a></p>
<p><em><strong>On a serious note, the code below is to be considered a hack. </strong></em> It requires modifying core system files, and as such it will have to be reapplied after each ExpressionEngine update. There may also be a future update that breaks it all together.</p>
<h2>Modifying the communicate controller</h2>
<p>The first step is inserting some code into the communicate controller.  The file you want is:</p>
<pre class="brush: php;">system/expressionengine/controllers/cp/tools_communicate.php</pre>
<p>This file controls the rendering of the Communicate panel.  We dont need to do anything very complicated in the backend, since all we want to do is add a list of the templates to the control panel and then have this added to the message textarea when its selected.</p>
<p>Add this at around line 274:</p>
<pre class="brush: php;">
		$this-&gt;javascript-&gt;output('$(&quot;select#template&quot;).change(function(){
										$.get($(this).val(), function(data){
												$(&quot;#message&quot;).val(data);
										});});');
		$q = $this-&gt;template_model-&gt;get_templates();
		$qa = $q-&gt;result_array();
		$tmpl = array(&quot; &quot; =&gt; array(&quot; &quot; =&gt; &quot;None&quot;));
		for($i = 0; $i &lt; sizeof($qa); $i++){
				$tmpl[$qa[$i]['group_name']][site_url($qa[$i]['group_name'].&quot;/&quot;.$qa[$i]['template_name'])] = $qa[$i]['template_name'];
		}
		$vars['templates']	= 	$tmpl;
</pre>
<h2>Modifying the communicate view</h2>
<p>Since ExpressionEngine 2.0 is now based on the MVC pattern, we need to modify the view file that is used to render the communicate control panel. The file you want is:</p>
<pre class="brush: php;">themes/cp_themes/default/tools/communicate.php</pre>
<p>All you need to do is add the following at around line 59:</p>
<pre class="brush: php;">
		&lt;h3&gt;Template&lt;/h3&gt;
				&lt;ul class=&quot;shun&quot;&gt;
						&lt;li class=&quot;odd&quot;&gt;
						&lt;?php echo form_dropdown('template', $templates, '0', 'id=&quot;template&quot;')?&gt;
						&lt;/li&gt;
				&lt;/ul&gt;
</pre>
<p>You should now have a drop down list on your communicate panel that will allow you send your templates via email.</p>
<h4>Using non-standard site index name</h4>
<p>If you are using a non-standard site index name (ie: not index.php) then you may hit a problem where the template is not inserted into the message text area.  To fix this, find the config file:</p>
<pre class="brush: php;">system/expressionengine/config/config.php</pre>
<p>And then change the index page name at around line 49 to whatever you have named your index file:</p>
<pre class="brush: php;">
$config['index_page'] = 'index.php';
</pre>
<p>If you have any problems let me know in the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherimrie.com/2010/01/17/sending-expressionengine-2-0-templates-through-the-communicate-panel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Member List Custom Field for EE2</title>
		<link>http://www.christopherimrie.com/2010/01/12/member-list-custom-field-for-ee2/</link>
		<comments>http://www.christopherimrie.com/2010/01/12/member-list-custom-field-for-ee2/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 18:02:41 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[expressionengine]]></category>
		<category><![CDATA[field type api]]></category>
		<category><![CDATA[fieldtype]]></category>

		<guid isPermaLink="false">http://www.christopherimrie.com.php5-2.dfw1-1.websitetestlink.com/?p=56</guid>
		<description><![CDATA[
As an exercise for myself in figuring out the new Custom Field API, I have produced a custom field type that adds a list of your current site members to your publish forms. It also allows you to display different aspects of the selected member’s data in your templates such as email, screen name, group [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>As an exercise for myself in figuring out the new Custom Field API, I have produced a custom field type that adds a list of your current site members to your publish forms. It also allows you to display different aspects of the selected member’s data in your templates such as email, screen name, group title.</p>
<p>I thought I might as well share it in case someone finds it useful.</p>
<p>There are things that aren’t supported yet which I will be implementing such as restricting to member groups and returning custom member fields.</p>
<p><em><span id="more-56"></span>Tip of the hat goes to Leevi Graham’s Member List field type for EE 1.6.x which I have been using for a while now, and inspired the creation of this field type for EE2.0</em></p>
</div>
<div>
<h4><a href="http://github.com/ckimrie/cki.member_list.ee_addon/tarball/master">Download cki.member_list.ee_addon</a></h4>
<p><a href="http://github.com/ckimrie/cki.member_list.ee_addon">Github Repository</a></p>
<h2>Requirements</h2>
<ul>
<li>ExpressionEngine 2.0</li>
</ul>
<h2>Installation</h2>
<ul>
<li>Copy <code>ft.cki_mblist.php</code> to your <code>system/expressionengine/fieldtypes/</code> folder.</li>
<li>Select <strong>CKI Member List</strong> as the field type when creating a new custom field type</li>
</ul>
<h2>How to use</h2>
<p>The field type supports single tag and tag pairs, depending on whether you want more than one element of member data at any one time.</p>
<p>The member_id of the selected member can be produced by simply using the Field name of your custom field with no parameters. If you want to retrieve a specific item of member data, you can use the <code>get</code> parameter to specify what data you want returned.</p>
<h3>Simple Example</h3>
<p>Lets say you have defined a custom field with a field label of <strong>Member_list</strong> and field name <strong>member_list</strong> and through the publish form selected a member with an ID of 3. You can produce the Member ID of the selected member by simply calling the field name tag on its own:</p>
<pre class="brush: xml;">
		{exp:channel:entries channel=&quot;blog&quot;}
			&lt;p&gt;You selected member ID {member_list}&lt;/p&gt;
		{/exp:channel:entries}
</pre>
<p><strong>Returns:</strong></p>
<pre class="brush: xml;">
	&lt;p&gt;You selected member ID 3&lt;/p&gt;
</pre>
<h3>Parameter Example</h3>
<p>Using the same member you have selected in the above example, we can retrieve this member’s email address by using the <code>get</code> parameter:</p>
<pre class="brush: xml;">
		{exp:channel:entries channel=&quot;blog&quot;}
			&lt;p&gt;You selected member email is {member_list get=&quot;email&quot;}&lt;/p&gt;
		{/exp:channel:entries}
</pre>
<p><strong>Returns:</strong></p>
<pre class="brush: xml;">
	&lt;p&gt;Your selected member email is john@smith.com&lt;/p&gt;
</pre>
<h3>Tag Pair Example</h3>
<p>If you are looking to display a block of many pieces of member data within a template, it will most be likely be useful to use the tag pairs, as they can allow you reduce the amount of markup needed. The <code>get</code> parameter is ignored when using tag pairs.</p>
<p>Using the same scenario as described in the example above, you could do the following with tag pairs:</p>
<pre class="brush: xml;">
		{exp:channel:entries channel=&quot;blog&quot;}
			{member_list}
				&lt;p&gt;Name: {screen_name}&lt;/p&gt;
				&lt;p&gt;Email: {email}&lt;/p&gt;
				&lt;p&gt;Member of: {group_title}&lt;/p&gt;
			{/member_list}
		{/exp:channel:entries}
</pre>
<p><strong>Returns:</strong></p>
<pre class="brush: xml;">
		&lt;p&gt;Name: John Smith&lt;/p&gt;
		&lt;p&gt;Email: john@smith.com&lt;/p&gt;
		&lt;p&gt;Member of: Super Admin&lt;/p&gt;
</pre>
<h2>Parameters</h2>
<h3>Get</h3>
<pre class="brush: xml;">
	get=&quot;screen_name&quot;
</pre>
<p>Allows you to specify what member data to return. Accepts field names of the <em>exp_members</em> and <em>exp_member_groups</em> database tables.</p>
<p>Some valid field name examples:</p>
<ul>
<li><em>member_id</em></li>
<li><em>username</em></li>
<li><em>screen_name</em></li>
<li><em>email</em></li>
<li><em>group_title</em></li>
<li><em>bio</em></li>
<li><em>avatar_filename</em></li>
</ul>
<h2>Changelog</h2>
<p><strong>1.1.1</strong></p>
<ul>
<li>Fixed bug for when using single field tags in templates</li>
</ul>
<p><strong>1.1</strong></p>
<ul>
<li>Separated members into member groups in publish form drop down list</li>
<li>Updated member existence checker</li>
</ul>
<p><strong>1.0</strong></p>
<ul>
<li>Initial Commit</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherimrie.com/2010/01/12/member-list-custom-field-for-ee2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSM Site List Custom Field for EE2</title>
		<link>http://www.christopherimrie.com/2010/01/12/msm-site-list-custom-field-for-ee2/</link>
		<comments>http://www.christopherimrie.com/2010/01/12/msm-site-list-custom-field-for-ee2/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 16:08:53 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[fieltypes]]></category>

		<guid isPermaLink="false">http://www.christopherimrie.com.php5-2.dfw1-1.websitetestlink.com/?p=43</guid>
		<description><![CDATA[Just created this EE2.0 field type as I wanted the control panel users to be able to select which site their channel entries get shown on, as opposed to hard coding this via the templates, or having the user switch between sites.
Using some simple filters in your templates, (eg query module) you can grab channel [...]]]></description>
			<content:encoded><![CDATA[<p>Just created this EE2.0 field type as I wanted the control panel users to be able to select which site their channel entries get shown on, as opposed to hard coding this via the templates, or having the user switch between sites.</p>
<p>Using some simple filters in your templates, (eg query module) you can grab channel entries and filter by the custom field you have setup.</p>
<p>The fieldtype records the site short name in the database, but this can be converted to the site label, id or description via the <em>display</em> parameter.</p>
<p><span id="more-43"></span></p>
<h3><a href="http://github.com/ckimrie/ft.cki_sitelist.ee_addon/tarball/master">Download ft.cki_sitelist.ee_addon</a></h3>
<p><a href="http://github.com/ckimrie/ft.cki_sitelist.ee_addon">Github repository</a></p>
<h2>Requirements</h2>
<ul>
<li>ExpressionEngine 2.0</li>
</ul>
<h2>Installation</h2>
<ul>
<li>Copy <code>ft.cki_sitelist.php</code> to your <code>system/expressionengine/fieldtypes/</code> folder.</li>
<li>Select <strong>CKI Site List</strong> as the field type when creating a new custom field type</li>
</ul>
<h2>How to use</h2>
<p>The field type supports single tags only.  Use the tag on its own to return the selected site short_name_</p>
<h3>Simple Example</h3>
<p>Lets say you have defined a custom field with a field label of <strong>Site list</strong> and field name <strong>site_list</strong> and through the publish form selected a site with an short_name of “default_site”. You can produce the site short name of the selected site by simply calling the field name tag on its own:</p>
<pre class="brush: xml;">
		{exp:channel:entries channel=&quot;blog&quot;}
			&lt;p&gt;You selected site short name is {site_list}&lt;/p&gt;
		{/exp:channel:entries}
</pre>
<p><strong>Returns:</strong></p>
<pre class="brush: xml;">
			&lt;p&gt;You selected site short name is {site_list}&lt;/p&gt;
</pre>
<h3>Parameter Example</h3>
<p>Using the same site you have selected in the above example, we can retrieve different site attributes by using the <code>display</code> parameter:</p>
<pre class="brush: xml;">
		{exp:channel:entries channel=&quot;blog&quot;}
			&lt;p&gt;You selected site ID is {site_list display=&quot;id&quot;}&lt;/p&gt;
		{/exp:channel:entries}
</pre>
<p><strong>Returns:</strong></p>
<pre class="brush: xml;">
			&lt;p&gt;You selected site ID is 1&lt;/p&gt;
</pre>
<h2>Parameters</h2>
<h3>Display</h3>
<pre class="brush: xml;">
	display=&quot;label&quot;
</pre>
<p>Allows you to specify what site attribute to return. This parameter is optional, and if not used, the tag will return the site short name by default.</p>
<p>Accepts the following variables:</p>
<ul>
<li><em>id</em> – Return the site id</li>
<li><em>label</em> – Returns the site label</li>
<li><em>short_name</em> – Returns the site short name</li>
<li><em>description</em> – Returns the site description</li>
</ul>
<h2>Changelog</h2>
<p><strong>1.0</strong></p>
<ul>
<li>Initial Commit</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherimrie.com/2010/01/12/msm-site-list-custom-field-for-ee2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Talking to ExpressionEngine’s MetaWeblog API with CodeIgniter</title>
		<link>http://www.christopherimrie.com/2010/01/12/talking-to-expressionengines-metaweblog-api-with-codeigniter/</link>
		<comments>http://www.christopherimrie.com/2010/01/12/talking-to-expressionengines-metaweblog-api-with-codeigniter/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 00:50:00 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[expressionengine]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[xml-rpc]]></category>

		<guid isPermaLink="false">http://www.christopherimrie.com.php5-2.dfw1-1.websitetestlink.com/?p=19</guid>
		<description><![CDATA[On a recent project I had the need to interface between ExpressionEngine (1.6.8) and CodeIgniter.
There are several situations where this is very useful even if you know ExpressionEngine’s module and extension development API’s like the back of your hand.  More often than not it’s just easier to use the Metaweblog API since it ships with [...]]]></description>
			<content:encoded><![CDATA[<p>On a recent project I had the need to interface between ExpressionEngine (1.6.8) and CodeIgniter.</p>
<p>There are several situations where this is very useful even if you know ExpressionEngine’s module and extension development API’s like the back of your hand.  More often than not it’s just easier to use the <a href="http://www.xmlrpc.com/metaWeblogApi">Metaweblog API </a>since it ships with the system.</p>
<p>In my case I had a page that included a form with some validation functionality that required, among other things, to have the user confirm via email as well as store some custom data in a database for other uses.  As the rest of the website was being run on ExpressionEngine,  I wanted the users data posted into the ExpressionEngine system once all the validation and custom scripts had been executed so that it could be managed via the control panel.</p>
<p><span id="more-19"></span>However well you know ExpressionEngine, inserting directly into the ExpressionEngine database is always a bad idea, since EllisLab may update the database structure and then your custom script could end up wreaking havoc on the database.  So I decided very early on that the Metaweblog API was the way to go.</p>
<p>After looking around on the net, I couldn&#8217;t find any good tutorials on how to get CodeIgniter to talk to the Metaweblog API so I figured I’d write my own.</p>
<h2>XML -RPC</h2>
<p>The Metaweblog API works over what is known as <a href="http://www.xmlrpc.com/">XML -RPC</a>.  Its a pretty common data interchange format that is designed to be simpler than methods such as <a href="en.wikipedia.org/wiki/SOAP">SOAP</a>.  It works by sending data encoded in a certain XML structure to a server that then processes the data.</p>
<p>If you’re like me, you’ll find reading the official xml-rpc specification to be a little dry and tricky to put into practice in terms of coding a solution from scratch.  Luckily for us, CodeIgniter has a built in XML-RPC server and client library that can get us up and running quickly.</p>
<h2>CodeIgniter’s XML-RPC Class</h2>
<p>This isn’t a tutorial on how to use CodeIgniter, so if you need a primer on that then check out the <a href="http://codeigniter.com/user_guide/">official user documentation</a>.  I still believe its the best written user documentation out there.</p>
<p>The CodeIgniter <a href="http://codeigniter.com/user_guide/libraries/xmlrpc.html">XML-RPC documentation</a> is a great resource on how to use the the client library, however, its not exactly easy to apply it to the Metaweblog API.  After a bit of trial and error I figured it out and although it is very simple I discovered that there are some restrictions to using it.</p>
<h2>Setting up ExpressionEngine</h2>
<p>Firstly, you&#8217;ll have to install the Metaweblog API module in your ExpressionEngine install.  You&#8217;ll find this, obviously, under the Modules tab of the control panel.  Once installed you can click on the Metaweblog API to change the settings. Once installed you&#8217;ll see something like this:</p>
<p style="text-align: center;"><a href="http://www.christopherimrie.com.php5-2.dfw1-1.websitetestlink.com/wp-content/uploads/2010/01/config.jpg"><img class="size-full wp-image-28 aligncenter" title="config" src="http://www.christopherimrie.com.php5-2.dfw1-1.websitetestlink.com/wp-content/uploads/2010/01/config.jpg" alt="" width="620" height="280" /></a></p>
<p style="text-align: left;"><em>Make a note of the URL on the configuration page since you will need it later</em></p>
<p style="text-align: left;">When using the Metaweblog API  each script or weblog you want to interface with will need its own configuration.  The reason for this is that xml-rpc can only carry so much information, and it is designed for interfacing with simpler blogging systems such as Blogger or Wordpress, where there is one blog made up of the following fields:</p>
<ul>
<li>Excerpt</li>
<li>Content</li>
<li>More Content</li>
<li>Keywords</li>
</ul>
<p>If you&#8217;re an ExpressionEngine developer though, you&#8217;ll know that the beauty of EE is that you don&#8217;t need to follow this pattern and you can choose your own. So when using the Metaweblog API, you need to map the incoming excerpt, content, more &amp; keyword fields to your own fields.  You dont need to map them all, you just need to choose what incoming data is going where.</p>
<p>When you click on the name of the configuration you want to edit, you&#8217;ll be presented with the following options:</p>
<p><a href="http://www.christopherimrie.com.php5-2.dfw1-1.websitetestlink.com/wp-content/uploads/2010/01/config2.jpg"><img class="aligncenter size-full wp-image-30" title="config2" src="http://www.christopherimrie.com.php5-2.dfw1-1.websitetestlink.com/wp-content/uploads/2010/01/config2.jpg" alt="" width="620" height="439" /></a>Now although it looks like there are several input data fields you can use, the many here are actually for the <strong>MoveableType API</strong> which is also part of this module ( though its not really written anywhere).  <em>So for incoming data, you can only use the Content field.</em></p>
<h4>Configuration Name</h4>
<p style="padding-left: 30px;"><em>Enter the name of this configuration. You can leave this as Default, unless you are using more than one interface configuration.</em></p>
<h4>Text Formatting Preference</h4>
<p style="padding-left: 30px;"><em>Choose whether you want ExpressionEngine to parse any EE tags in the incoming data</em></p>
<h4>Entry Status</h4>
<p style="padding-left: 30px;"><em>You can choose what status to apply to the incoming data when it is inserted into the database, or allow it to be specified by the incoming data (more on this later).</em></p>
<h4>Channel Field Group</h4>
<p style="padding-left: 30px;"><em>Select the ExpressionEngine field group you want data inserted into. You must keep in mind that when you are sending data from CodeIgniter, you can specify the weblog to be posted into, </em><em><strong>however</strong>, make sure that you select the corresponding field group for that weblog here.</em></p>
<h4>Excerpt Field</h4>
<p style="padding-left: 30px;"><em><strong>MoveableType API  only -</strong> Select what field you want the incoming excerpt data inserted into. The field must be a textarea.</em></p>
<h4>Content Field</h4>
<p style="padding-left: 30px;"><em>Select what field you want the incoming content data inserted into. The field must be a textarea.</em></p>
<h4>More Field</h4>
<p style="padding-left: 30px;"><em><strong>MoveableType API  only -</strong> </em><em>Select what field you want the incoming more data inserted into. The field must be a textarea.</em></p>
<h4>Keywords Field</h4>
<p style="padding-left: 30px;"><em><strong>MoveableType API  only -</strong> </em><em>Select what field you want the incoming keyword data inserted into. The field must be a textarea.</em></p>
<h4>Upload directory for file uploading</h4>
<p style="padding-left: 30px;"><em>If you are uploading files (although not covered here) you can specify where you want those files to be delivered.</em></p>
<p>So keep in mind that since we are using the Metaweblog API we can only use the Content area for incoming data, and also that the field it gets mapped to must be a textarea.</p>
<h2>Setting up CodeIgniter</h2>
<p>The code needed in order get the xml-rpc class talking to ExpressionEngine is pretty simple.  All you need to do is load the library in your controller.  Here i am loading the library in the controller constructor.</p>
<pre class="brush: php;">
class Metaweblog extends Controller {

	function Metaweblog()
	{
		parent::Controller();

		//load the library
		$this-&gt;load-&gt;library('xmlrpc');
	}
}
</pre>
<p>Once the library is loaded, you need to specify the server address.</p>
<pre class="brush: php;">
class Metaweblog extends Controller {

	function Metaweblog()
	{
		parent::Controller();

		//load the library
		$this-&gt;load-&gt;library('xmlrpc');

		//specify the server address
		$this-&gt;xmlrpc-&gt;server($this-&gt;config-&gt;item('metaweblog_url'));

	}
}
</pre>
<p>The Metaweblog API has various methods that can be used (eg: Editing, Deleting etc) but in this case we want to post a new item.  So we need to specify the method:</p>
<pre class="brush: php;">
class Metaweblog extends Controller {

	function Metaweblog()
	{
		parent::Controller();

		//load the library
		$this-&gt;load-&gt;library('xmlrpc');

		//specify the server address
		$this-&gt;xmlrpc-&gt;server($this-&gt;config-&gt;item('metaweblog_url'));

		//Choose the metaWeblog API method
		$this-&gt;xmlrpc-&gt;method('metaWeblog.newPost');
	}
}
</pre>
<p>So now our configurations are in, we just have to format the xml to the correct structure.  Using the library in CodeIgniter, we set the structure of the resulting xml by creating an array():</p>
<pre class="brush: php;">
		//Setup paramaters for posting
		$data = array(
			//Param[0]: Weblog ID
			&quot;weblog ID&quot;,
			//Param[1]: Username
			&quot;username&quot;,
			//Param[2]:Password
			&quot;password&quot;,
			//Param[3]:Data
			array(
					array(
						'title' 		=&gt;	&quot;Title of the weblog&quot;,
						'description'	=&gt;	&quot;Content of the weblog data being posted&quot;
						//This is needed for the array to be recognized
						), &quot;struct&quot;
				),
			//Param[4]:Status
			1
			);
</pre>
<p>I&#8217;ve commented the code above, so its pretty self explanatory.  As you can see, you specify the title and description data.  Whatever is in the description will be inserted into the field you chose to map the &#8220;Content field&#8221; to in the ExpressionEngine Metaweblog API module settings.</p>
<p>Once we&#8217;ve set this array up, we then add the array to the xml-rpc library and send the request.  So once this is all put together, the full controller looks like so:</p>
<pre class="brush: php;">
class Metaweblog extends Controller {

	function Metaweblog()
	{
		parent::Controller();

		//load the library
		$this-&gt;load-&gt;library('xmlrpc');

		//specify the server address
		$this-&gt;xmlrpc-&gt;server($this-&gt;config-&gt;item('metaweblog_url'));

		//Choose the metaWeblog API method
		$this-&gt;xmlrpc-&gt;method('metaWeblog.newPost');
	}

 	function publish()
	{
		//Setup paramaters for posting
		$data = array(
			//Param[0]: Weblog ID
			&quot;weblog ID&quot;,
			//Param[1]: Username
			&quot;username&quot;,
			//Param[2]:Password
			&quot;password&quot;,
			//Param[3]:Data
			array(
					array(
						'title' 		=&gt;	&quot;Title of the weblog&quot;,
						'description'	=&gt;	&quot;Content of the weblog data being posted&quot;
						//This is needed for the array to be recognized
						), &quot;struct&quot;
				),
			//Param[4]:Status
			1
			);

			//Add the array to the xml-rpc library
			$this-&gt;xmlrpc-&gt;request($data);

			//Make the request
			$this-&gt;xmlrpc-&gt;send_request();
}
}
</pre>
<p>And thats it!</p>
<p>If you are having trouble with the data, and want to know what is going on, you can turn on the debug mode by adding the following line in the contructor of your controller:</p>
<pre class="brush: php;">
		$this-&gt;xmlrpc-&gt;set_debug(TRUE);
</pre>
<p>Hope this is of help to anyone.  If you have any questions, make your voice heard below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherimrie.com/2010/01/12/talking-to-expressionengines-metaweblog-api-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
