<?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>Blog: Raised Eyebrow Web Studio, Inc. &#187; Geekery</title>
	<atom:link href="http://blog.raisedeyebrow.com/category/geekery/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.raisedeyebrow.com</link>
	<description>What's turning heads at Raised Eyebrow</description>
	<lastBuildDate>Thu, 15 Jul 2010 15:19:02 +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>Confessions of a Late-Blooming Gamer</title>
		<link>http://blog.raisedeyebrow.com/2010/07/confessions-of-a-late-blooming-gamer/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=confessions-of-a-late-blooming-gamer</link>
		<comments>http://blog.raisedeyebrow.com/2010/07/confessions-of-a-late-blooming-gamer/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 15:29:33 +0000</pubDate>
		<dc:creator>Lauren Bacon</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Geekery]]></category>

		<guid isPermaLink="false">http://blog.raisedeyebrow.com/?p=978</guid>
		<description><![CDATA[What Video Games Are Teaching Me About Motivation and Behaviour
I have a terrifying confession to make: Until very recently, I didn&#8217;t play video games.
That may not be particularly appalling to many of you, but for someone in my industry, that&#8217;s pretty embarrassing. Game designers are an integral part of the interactive design community, and I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<h3>What Video Games Are Teaching Me About Motivation and Behaviour</h3>
<p>I have a terrifying confession to make: Until very recently, I didn&#8217;t play video games.</p>
<p>That may not be particularly appalling to many of you, but for someone in my industry, that&#8217;s pretty embarrassing. Game designers are an integral part of the interactive design community, and I&#8217;ve always felt an affinity with them, despite not really knowing their territory. In fact, <a href="http://clicknothing.typepad.com/">one of my favourite blogs</a> is written by Clint Hocking, a former creative director at <a href="http://www.ubi.com">Ubisoft</a> (and high school friend of mine). But I have long been more than a little sheepish about publicly admitting to not having a clue about gaming, aside from what I&#8217;ve read on Clint&#8217;s blog.</p>
<p>That said, it&#8217;s always educational to be late on the uptake with a particular technology; as a web designer I feel like it can help me empathize with the people using my designs who might not spend even a fraction of the time I spend online. I&#8217;ve learned a few things from my experience that feel particularly relevant to the work we do with our clients.</p>
<p>First, I had valid reasons for not playing video games until now. I didn&#8217;t have access to a console; I didn&#8217;t feel like spending money on one until its value had been shown to me; I had seen a lot of games that didn&#8217;t appeal to my interests and sensibilities; and perhaps most fundamentally, I was so green that even working the controller was daunting to me &#8212; that is, the basics of navigation and control felt uncomfortable and clunky. All of these practical resistance points are also true for many website users; even now when those of us in the industry refer to ourselves as &#8220;veterans&#8221; and to the up-and-coming generation as &#8220;digital natives,&#8221; there are still huge swaths of people on the planet who simply don&#8217;t <em>need </em>to use the internet to get through their days &#8212; as my uncle Ken, a farmer &amp; logger in Northern Ontario, reminds me regularly. For those people, the only thing that&#8217;s going to make them interested in the technology is for it to become relevant to their lives.</p>
<p>It wasn&#8217;t until I discovered a game that I truly fell in love with (more on that in a moment) that I became invested enough to want to work through my painful awkwardness with the controller and my hesitations about the financial investment. (I haven&#8217;t touched on the time investment required, which is significant &#8212; this was another fear I had about games, and one that proved well-founded as I have found myself losing all track of time while immersed in the gaming experience.) But once I found a game I connected with, the obstacles fell away and my desire to interact with the game overcame all resistance. Us web designers are fond of parroting the maxim that &#8220;Content is king,&#8221; but we haven&#8217;t always been good at practicing what we preach &#8212; this has been a good reminder to me that what&#8217;s inside really is what counts. And just as all websites aren&#8217;t created with equal amounts of attention to content, neither are all video games.</p>
<p><img class="alignleft size-medium wp-image-979" title="Assassin's Creed II capture" src="http://blog.raisedeyebrow.com/wp-content/uploads/2010/07/assassins-creed2-431-300x208.jpg" alt="" width="300" height="208" />The game that stole my heart is <a href="http://en.wikipedia.org/wiki/Assassin%27s_Creed_II">Assassin&#8217;s Creed II</a>, an action-adventure game set in Renaissance Italy. Your character is a young assassin from a noble family who is avenging a betrayal of his family &#8212; but it&#8217;s actually far more complicated than that. You&#8217;re <em>actually</em> a modern-day guy who&#8217;s been projected back into the body of this 15th-century assassin, and you&#8217;re trying to solve a mystery involving the <a href="http://en.wikipedia.org/wiki/Knights_Templar">Knights Templar</a> that traverses centuries. In the process, you travel through the gorgeously-rendered streets of Florence, Venice, and points in between, running over rooftops, climbing church towers, dodging guards, exploring secret tombs, hiding in crowds, stealing treasure, and oh yes &#8212; hanging out with Leonardo da Vinci. There are puzzles to solve, swordfights, thieving missions, and even some economic development to manage in a small town where your uncle&#8217;s villa is located.</p>
<p>The premise itself appeals to me more than some other games, but the real genius of Assassin&#8217;s Creed II lies in its execution. Game designers clearly put an enormous amount of thought into human motivation, and there&#8217;s something in this game for just about anyone. The rewards that you earn over the course of the game are a mix of financial (good old-fashioned cash), status (your armour and weapons get progressively better &#8212; and pricier &#8212; as you progress), relational (you meet new characters &amp; gain access to allies) and intellectual (solving puzzles). It&#8217;s been interesting to observe my responses to the various types of rewards and see how they correspond with my real-life predilections. I think the real hook for me has been the mystery-solving part, because it lends an over-arching mission and urgency to the game that I have only ever felt when reading a complex and layered page-turner of a novel.</p>
<p>I honestly never imagined that a video game could make me feel so immersed, and provide such a strong emotional connection. Now that I&#8217;ve had this experience I&#8217;m far more likely to explore the rest of the gaming world and see what else is out there. But it&#8217;s also got me thinking about the factors that shift behaviour and that motivate us &#8212; which makes me further resolved to focus my summer reading on those topics. I&#8217;ve picked up <a href="http://heathbrothers.com/switch/"><em>Switch</em></a> and <a href="http://heathbrothers.com/madetostick"><em>Made to Stick</em></a> (both by Chip &amp; Dan Heath) but I welcome other suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.raisedeyebrow.com/2010/07/confessions-of-a-late-blooming-gamer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Datadotgc.ca &#8211; A Drupal case study: Part 2</title>
		<link>http://blog.raisedeyebrow.com/2010/06/datadotgc-ca-a-drupal-case-study-part-2/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=datadotgc-ca-a-drupal-case-study-part-2</link>
		<comments>http://blog.raisedeyebrow.com/2010/06/datadotgc-ca-a-drupal-case-study-part-2/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 19:23:41 +0000</pubDate>
		<dc:creator>Colin Calnan</dc:creator>
				<category><![CDATA[Code and Coding]]></category>
		<category><![CDATA[Content Management Systems]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CKAN]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.raisedeyebrow.com/?p=880</guid>
		<description><![CDATA[This is the second part of Drupal Case Study on integrating the CKAN data repository with Drupal 6. Part 1 covered the following:

What is CKAN?
CKAN’s API
The Foundation
The Build
Theming
Homepage Chart

Caching
API calls are expensive. There&#8217;s no doubt about that. Particularly when you&#8217;re returning large amounts of data. To avoid any issues of the CKAN API being exhausted [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second part of Drupal Case Study on integrating the CKAN data repository with Drupal 6. <a href="/2010/04/datadotgc-ca-a-drupal-case-study/">Part 1 covered the following</a>:</p>
<ul>
<li>What is CKAN?</li>
<li>CKAN’s API</li>
<li>The Foundation</li>
<li>The Build</li>
<li>Theming</li>
<li>Homepage Chart</li>
</ul>
<h3>Caching</h3>
<p>API calls are expensive. There&#8217;s no doubt about that. Particularly when you&#8217;re returning large amounts of data. To avoid any issues of the CKAN API being exhausted from requests and to ensure that the site remained responsive, I decided to leverage Drupals caching mechanisms and pretty much cached everything I could, within reason. <a href="http://www.datadotgc.ca">The Chart</a>, Tag Cloud, <a href="http://www.datadotgc.ca/data/tag">Tag lists</a>, <a href="http://www.datadotgc.ca/data/ministry">Ministry lists</a>, <a href="http://www.datadotgc.ca/data/all">All Packages</a> list and all individual packages are cached. The issue with caching on this site is that if a package gets updated on the CKAN instance, we need to know about that on our Drupal site immediately and then clear the appropriate caches so that the most recent data can be retrieved. </p>
<p>For caching I created a table called &#8216;cache_ckan&#8217;, that stores everything I need. To create this table I used the schema of the existing cache table and put that in my .install file in my module directory.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p880code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8808"><td class="code" id="p880code8"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Implementation of hook_install().
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> ckan_install<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  drupal_install_schema<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Implementation of hook_uninstall().
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> ckan_uninstall<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  drupal_uninstall_schema<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Implementation of hook_schema().
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> ckan_schema<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$schema</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$schema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cache_ckan'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> drupal_get_schema_unprocessed<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'system'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$schema</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Whenever this module is enabled this schema will be run and the table will be created.</p>
<h4>What is stored in the ckan_cache table?</h4>
<p>There are various items stored in the cache table.</p>
<ol>
<li>The Homepage chart data</li>
<li>Tag lists</li>
<li>Ministry lists</li>
<li>List of all datasets</li>
</ol>
<p>Let&#8217;s take the <a href="http://www.datadotgc.ca/data/all">list of all packages</a> as an example. I covered how I implemented the paging in <a href="/2010/04/datadotgc-ca-a-drupal-case-study/">my previous post</a>. As this list is paginated it&#8217;s important that every page be cached to improve the speed of the site. As the paging mechanism is already implemented it&#8217;s just a case of creating a cache table entry (<strong>ckan:all{page-number}</strong>) for each page, and then checking for it&#8217;s existence when loading the page.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p880code9'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8809"><td class="code" id="p880code9"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span> <span style="color: #339933;">=</span> cache_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan:all'</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// If cached data exists for this page...</span>
	<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$ckan</span> <span style="color: #339933;">=</span> ckan_ckan<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$items_per_page</span> <span style="color: #339933;">=</span> variable_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_items_per_page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// If we're in a page, we need to set where to start the list</span>
		<span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$page</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$items_per_page</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Set the offset to the number of records in</span>
	<span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$start</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Limit to the number of items per page </span>
	<span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$items_per_page</span><span style="color: #339933;">;</span>
&nbsp;
	try <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">advancedSearch</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'groups'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'canadagov'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all_fields'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'offset'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'limit'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// If the API call worked</span>
	watchdog<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Called CKAN API for list of all packages'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	cache_set<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan:all'</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This method is very simple and very effective. It means the pages load lightning fast and only one page of data at a time is retrieved.</p>
<h4>How does the cache get cleared/updated</h4>
<p>Datasets/Packages change all the time on the CKAN instance, so how do you make sure that the Drupal site has the most current data. This module has two ways of managing that.</p>
<h4>1. Using <a href="http://api.drupal.org/api/function/hook_form/6">hook_form</a> to redirect to CKAN</h4>
<p>As the CKAN nodes on Drupal are created on the fly and hold very little information, there is really no need to access the EDIT form for these nodes. Whenever an admin user clicks the edit tab on the node, they are automatically redirected to the appropriate CKAN package editing screen. hook_form is called to retrieve the form that is displayed when one attempts to &#8220;create/edit&#8221; an item. For CKAN content types, the user is redirect to the CKAN instance.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p880code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p88010"><td class="code" id="p880code10"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Implementation of hook_form
 *
 * Redirect the user to ca.ckan.net package edit screen on edit
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> ckan_form<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #000088;">$form_state</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'ckan'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  	drupal_goto<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://ca.ckan.net/package/edit/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>When the CKAN form is submitted, CKAN then redirects back to the Drupal site and calls a specific URL that tells Drupal to call CKAN again to get the package information and populate the node. To clarify, the process is</p>
<ol>
<li>Redirect http://www.datadotgc.ca/node/X/edit to http://ca.ckan.net/package/edit/{name of X}</li>
<li>On save of CKAN Package, redirect to http://www.datadotgc.ca/{special_url}/{name_of_X}</li>
<li>Load the node with {name_of_X}</li>
<li>Call CKAN to get the (updated) data for Package {name_of_X}</li>
<li>Save the node with updated data</li>
</ol>
<h4>Using Cron and an Atom Feed</h4>
<p>CKAN provides an Atom feed of recent updates to the Packages. Cron checks this feed every time it runs. If the feed has changed since the last cron run, then we know there have been updates and we clear all of the caches.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p880code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p88011"><td class="code" id="p880code11"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Implementation of hook_cron()
 *
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> ckan_cron<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Get the md5sum of the current atom feed</span>
	<span style="color: #000088;">$current_feed</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/md5_file"><span style="color: #990000;">md5_file</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://ca.ckan.net/revision/list?format=atom'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	watchdog<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Current feed md5: '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$current_feed</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Retrieve the previously stored md5sum</span>
	<span style="color: #000088;">$previous_feed</span> <span style="color: #339933;">=</span> variable_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_atom_feed_md5'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$current_feed</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	watchdog<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Previous feed md5: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$previous_feed</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// If there have been changes</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_feed</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$previous_feed</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		watchdog<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ATOM feed has updated, clearing caches and deleting nodes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Flush all the caches</span>
		cache_clear_all<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_ckan'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  	        <span style="color: #666666; font-style: italic;">// Set the previous feed md5</span>
		variable_set<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_atom_feed_md5'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$current_feed</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>Tag cloud creation</h3>
<p>I borrowed some code from the <a href="http://drupal.org/project/tagadelic">Tagadelic</a> module to achieve the tag cloud</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p880code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p88012"><td class="code" id="p880code12"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Build a tag cloud based on the settings provided
 *
 * @return	String	A themed list of weighted tags
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> ckan_tag_cloud<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// If there is cached data</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span> <span style="color: #339933;">=</span> cache_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan:tags'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/unserialize"><span style="color: #990000;">unserialize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$ckan</span> <span style="color: #339933;">=</span> ckan_ckan<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTagCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		watchdog<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Called CKAN API for tag cloud'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		cache_set<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan:tags'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/serialize"><span style="color: #990000;">serialize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Let's sort them by weight first off</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$tag</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$weight</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<a href="http://www.php.net/array_multisort"><span style="color: #990000;">array_multisort</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$weight</span><span style="color: #339933;">,</span> SORT_DESC<span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Now let's get the top X number of tags</span>
	<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_slice"><span style="color: #990000;">array_slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> variable_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_tagcloud_total'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">40</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Now build the tags</span>
	<span style="color: #000088;">$tags</span> <span style="color: #339933;">=</span> ckan_tag_build_weighted<span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Sort them</span>
	<span style="color: #000088;">$tags</span> <span style="color: #339933;">=</span> ckan_tag_sort<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Theme them</span>
	<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_weighted_tags'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tags</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Theme function that renders the HTML for the tags
 * @ingroup themable
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> theme_ckan_weighted_tags<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tag</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> l<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data/tag/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attributes'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;tagcloud level&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$tag</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'weight'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rel'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'tag'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>Using the CKAN Search API for all lists</h3>
<p>Ok, so what&#8217;s this all about? CKAN has some <a href="http://knowledgeforge.net/ckan/doc/ckan/api.html">nice API calls</a> like <em>/api/rest/package/PACKAGE-REF</em> that return a list of Packages. However these return the name/id of the Package ONLY. In our case, for our listings, we wanted other data, such as the tags attached to the Package as well as a brief description.</p>
<p>The only way to get this data was to do a search API call <em>/api/search/package</em> and pass some extra parameters, in this case <em><strong>all_fields=1</strong></em> and <em><strong>department={name of Ministry}</strong></em>. </p>
<p><em><strong>all_fields=1</strong></em> tells the search to return all Package fields, not just the name/id; just as is if you called  <em>/api/rest/package/PACKAGE-REF</em>.</p>
<p><em><strong>department={name of Ministry}</strong></em> tells the search to return all packages that have a department of {name of Ministry}. <strong>The lovely folks at CKAN added this functionality for us on request</strong>.</p>
<p>What does this look like, well it&#8217;s pretty simple really. Call the <em>advancedSearch()</em> function. Pass it a few parameters and it returns you all the data you need. Here&#8217;s the function itself:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p880code13'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p88013"><td class="code" id="p880code13"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> advancedSearch<span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$querystring</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'='</span><span style="color: #339933;">.</span> <a href="http://www.php.net/urlencode"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">transfer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'api/search/package?'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$querystring</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$results</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> CkanException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Search Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$results</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And here is that function being called for the list of Ministry Packages. The offset and limit are for the paging mechanism:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p880code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p88014"><td class="code" id="p880code14"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Call the function</span>
<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">advancedSearch</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'department'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$ministry</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all_fields'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'offset'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'limit'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>There&#8217;s a lot more functionality in this module, more than I can go through in a blog post, even 5 posts. If you&#8217;re trying to integrate Drupal with a CKAN instance and are not sure where to start then please leave a comment and I&#8217;ll get back in touch.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.raisedeyebrow.com/2010/06/datadotgc-ca-a-drupal-case-study-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Password Overload and CRMs</title>
		<link>http://blog.raisedeyebrow.com/2010/06/password-overload-and-crms/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=password-overload-and-crms</link>
		<comments>http://blog.raisedeyebrow.com/2010/06/password-overload-and-crms/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 22:08:17 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Raised Eyebrow]]></category>

		<guid isPermaLink="false">http://blog.raisedeyebrow.com/?p=926</guid>
		<description><![CDATA[When I used a PC, I found this utility that I used to keep track of my passwords.  Roboform is this happy will green dude who sits in your utility tray and keeps a list of all of your login accounts, their URLs, usernames, passwords and notes.  Launching an account is as easy as clicking [...]]]></description>
			<content:encoded><![CDATA[<p>When I used a PC, I found this utility that I used to keep track of my passwords.  <a title="Roboform" href="http://www.roboform.com/" target="_blank">Roboform</a><a title="Roboform" href="http://www.roboform.com/" target="_blank"><img class="alignright size-full wp-image-927" title="roboform" src="http://blog.raisedeyebrow.com/wp-content/uploads/2010/06/roboform.png" alt="" width="72" height="68" /></a> is this happy will green dude who sits in your utility tray and keeps a list of all of your login accounts, their URLs, usernames, passwords and notes.  Launching an account is as easy as clicking on Roboform and selecting the account you&#8217;d like to launch and voila the site launches and Roboform fills your username and password and automatically logs you in.  Roboform works with a master password, so when you login to your computer to launch Roboform you need to enter a master password.  You can set how often you want to be prompted for the password.</p>
<p>When I moved to Mac, I missed the little green guy.  Every time I had to copy a url, username and password from a spreadsheet and paste them manually into an internet browser, the heart ache increased.  Plus, there was all kinds of silliness with the spreadsheet: who had it open, who deleted that field, what is the most current version of the FTP info, etc.</p>
<p>When I migrated to Mac I had accumulated 249 passwords in my Roboform! The amount of information that people are beginning to need to be able to track in their personal and professional lives is outrageous.</p>
<p>At Raised Eyebrow we have thousands of passwords and they needed to be stored uber securely.  Moreover, the data is a more complex set of information, Client Names, Contact Info, FTP Info, Database Info, CMS Info, Host Info, Stats Info, etc.  We combed through the market of Mac-based password keepers. 1Password, KeePassX seemed to be the best options that emerged at the time.  <a title="1Password" href="http://agilewebsolutions.com/products/1Password" target="_blank">1Password</a>, which is proprietary, seemed more feature rich, while <a title="KeePassX" href="http://www.keepassx.org/" target="_blank">KeePass</a>, which is open source, seemed easier to install as a shared network installation.  Nonetheless, the amount of customization we required in terms of fields made neither solution appealing. So we kept on using a spreadsheet.</p>
<p>One day in utter frustration we had a brainstorming session.  We build websites, so maybe we could build an internal site that would keep our data?  From that session was born the idea for our super secure, one stop shop, password vault website.  That was 6 months ago.</p>
<p>Today, I just finished entering the last password from our main password list! What we developed in many respects is akin to a custom contact database.  We have different content types: Client, Website, Newsletter, Domain, etc.  Seeing the product, in its current state makes me wonder whether we should have invested the time we took to develop it into implementing and customizing a CRM (customer relationship manager)?  Could the data be accommodated in an off the shelf solution, like <a title="Salesforce" href="http://www.salesforce.com/" target="_blank">Salesforce</a> or <a title="Daylight" href="http://www.marketcircle.com/daylite/" target="_blank">Daylight</a> with customization?</p>
<p>Now, we are on the eve of embarking on a CRM implementation process. Starting such a process makes we wonder about all our systems: which ones work? Which ones should we keep? Which ones can be folded into the CRM? How can we streamline our workflow, while ensuring the integrity and security of our data?  How can specialized industries be best served by CRM software?</p>
<p>One major benefit from developing our password keeper is that we engaged in the exact process that would be required to clean up our data if we were going to import it into a CRM.  Instead of having a laundry list of every type of password in one long list, we have nice clean data parsed into types.  Also, it was like putting out a fire so that we wouldn&#8217;t be smoked out while we began to think about a CRM project. So, I&#8217;m happy with the path we&#8217;ve taken and looking forward to seeing what we do next.</p>
<p>If you have password overload, there are lots of solutions out there to make your life easier. And if you&#8217;ve recently done a CRM project in a all Mac environment, let me know how it went.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.raisedeyebrow.com/2010/06/password-overload-and-crms/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hey, Web Geeks With Hearts of Gold: We&#8217;re Hiring.</title>
		<link>http://blog.raisedeyebrow.com/2010/05/hey-web-geeks-with-hearts-of-gold-were-hiring/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=hey-web-geeks-with-hearts-of-gold-were-hiring</link>
		<comments>http://blog.raisedeyebrow.com/2010/05/hey-web-geeks-with-hearts-of-gold-were-hiring/#comments</comments>
		<pubDate>Fri, 28 May 2010 16:31:08 +0000</pubDate>
		<dc:creator>Lauren Bacon</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Nonprofit Tech]]></category>
		<category><![CDATA[Raised Eyebrow]]></category>

		<guid isPermaLink="false">http://blog.raisedeyebrow.com/?p=915</guid>
		<description><![CDATA[We&#8217;re excited to announce a new opportunity at Raised Eyebrow. Our little-web-studio-that-could is growing again, and we&#8217;ve got an opening for a Front-End Developer/Themer to help us build awesome websites for fabulous, mission-driven clients.
This is a position for someone with solid technical skills &#8212; someone who can rock HTML and CSS, who prides themselves on [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re excited to announce a new opportunity at Raised Eyebrow. Our little-web-studio-that-could is growing again, and we&#8217;ve got an opening for a <a href="http://raisedeyebrow.com/jobs/">Front-End Developer/Themer</a> to help us build awesome websites for fabulous, mission-driven clients.</p>
<p>This is a position for someone with solid technical skills &#8212; someone who can rock HTML and CSS, who prides themselves on attention to detail and clean, elegant code. You&#8217;ll be turning design comps into themes for Drupal and WordPress sites, so experience with one (or both) of those CMS&#8217;s is preferred, but if you&#8217;re confident in your coding skills and are new to Drupal &amp; WordPress, don&#8217;t let that stop you.</p>
<p>Because we&#8217;re a small shop, everyone here tends to wear a few hats, so we&#8217;re looking for someone with smarts, adaptability and a serious appetite for learning. We pride ourselves on the quality of our work, our efficiency, and our passion for our clients &#8212; and we&#8217;re looking for someone whose shares those values.</p>
<p>In our beautiful, heritage Gastown office, you&#8217;ll find a friendly team of experts, a ridiculously well-stocked tea cabinet, and abundant opportunities to work on projects that allow you to flex your technical muscles and bring your heart and ideals to work.</p>
<p>Sound like a fit for you (or someone you know)? <a href="http://raisedeyebrow.com/jobs/">The job description, with details on how to apply, is right here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.raisedeyebrow.com/2010/05/hey-web-geeks-with-hearts-of-gold-were-hiring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inexpensive Image Editing Tools: Format your photos on a budget</title>
		<link>http://blog.raisedeyebrow.com/2010/05/inexpensive-image-editing-tools-format-your-photos-on-a-budget/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=inexpensive-image-editing-tools-format-your-photos-on-a-budget</link>
		<comments>http://blog.raisedeyebrow.com/2010/05/inexpensive-image-editing-tools-format-your-photos-on-a-budget/#comments</comments>
		<pubDate>Tue, 18 May 2010 15:54:11 +0000</pubDate>
		<dc:creator>Lauren Bacon</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Nonprofit Tech]]></category>
		<category><![CDATA[Productivity]]></category>

		<guid isPermaLink="false">http://blog.raisedeyebrow.com/?p=902</guid>
		<description><![CDATA[We&#8217;re often asked for recommendations on image editing software that doesn&#8217;t cost an arm and a leg. Photoshop is fantastic, but the price tag is steep, and in fact, its strengths can also be weaknesses in that it&#8217;s actually such a powerful program that it can overwhelm the novice or intermediate user.
So, where do you [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re often asked for recommendations on image editing software that doesn&#8217;t cost an arm and a leg. <a href="http://www.adobe.com/products/photoshop/compare/">Photoshop</a> is fantastic, but the price tag is steep, and in fact, its strengths can also be weaknesses in that it&#8217;s actually such a powerful program that it can overwhelm the novice or intermediate user.</p>
<p>So, where do you turn if your needs are relatively straightforward and your budget is limited? I would recommend one of the following tools:</p>
<h2><a href="http://www.picnik.com/">Picnik</a></h2>
<p>Picnik is a powerful online application that allows you to upload &amp; edit images on the fly. There is a free version but the options are rather limited; however, it might do the trick for what your client needs. The premium version starts at $2.08/month. Picnik even integrates with <a href="http://www.flickr.com/">Flickr</a>, <a href="http://picasa.google.com">Picasa</a> &amp; <a href="http://www.facebook.com">Facebook</a>, so if your client uses those tools that might come in handy. I find it a little slow, compared to Photoshop (mostly because of the time required to upload &amp; download files), but it&#8217;s a very good tool for people with no/little budget.</p>
<h2><a href="http://www.adobe.com/products/photoshopelwin/">Photoshop Elements</a></h2>
<p>This is a stripped-down version of Photoshop that&#8217;s perfect for what most of our clients need, which is basic photo &amp; image editing tools for web use. It&#8217;s under $100 and provides a good chunk of the core Photoshop functionality &#8212; in some ways I would recommend it over Photoshop for basic-level users, because with fewer options it&#8217;s less confusing.</p>
<h2><a href="https://www.photoshop.com/">Photoshop.com</a></h2>
<p>Adobe&#8217;s answer to Picnik is an online editing toolset that you can use for free; the only limitation is file storage. The free accounts comes with 2 GB of storage space for your files, and beyond that you pay an annual subscription fee that varies (anywhere from $20-$500 USD) based on the amount of storage you need.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.raisedeyebrow.com/2010/05/inexpensive-image-editing-tools-format-your-photos-on-a-budget/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Datadotgc.ca &#8211; A Drupal case study</title>
		<link>http://blog.raisedeyebrow.com/2010/04/datadotgc-ca-a-drupal-case-study/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=datadotgc-ca-a-drupal-case-study</link>
		<comments>http://blog.raisedeyebrow.com/2010/04/datadotgc-ca-a-drupal-case-study/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 17:56:20 +0000</pubDate>
		<dc:creator>Colin Calnan</dc:creator>
				<category><![CDATA[Code and Coding]]></category>
		<category><![CDATA[Content Management Systems]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Nonprofit Tech]]></category>
		<category><![CDATA[CKAN]]></category>
		<category><![CDATA[Open data]]></category>

		<guid isPermaLink="false">http://blog.raisedeyebrow.com/?p=863</guid>
		<description><![CDATA[We recently launched http://www.datadotgc.ca, an open data collection portal for Canada, built to help poke the Canadian government in the right direction, towards something like similar sites in the UK (data.gov.uk) and the US (data.gov). Read David Eaves&#8217; explanation of its purpose. For the benefit of the programming and Drupal community, I&#8217;m going to run [...]]]></description>
			<content:encoded><![CDATA[<p>We recently launched <a href="http://www.datadotgc.ca">http://www.datadotgc.ca</a>, an open data collection portal for Canada, built to help poke the Canadian government in the right direction, towards something like similar sites in the UK (<a href="http://data.gov.uk">data.gov.uk</a>) and the US (<a href="http://data.gov">data.gov</a>). <a href="http://eaves.ca/2010/04/15/datadotgc-ca-launched-the-opportunity-and-challenge/">Read David Eaves&#8217; explanation of its purpose</a>. For the benefit of the programming and Drupal community, I&#8217;m going to run through, with the aid of code samples, the development of the Drupal module to communicate with the CKAN API (which is where the data is stored). I&#8217;ll also walk through Theming, integration with Google Charts, Tag Clouds and most importantly, caching.</p>
<h3>What is CKAN?</h3>
<blockquote><p>CKAN is a registry or catalogue system for datasets or other &#8220;knowledge&#8221; resources. CKAN aims to make it easy to find, share and reuse open content and data, especially in ways that are machine automatable.</p></blockquote>
<p>CKAN is a nice big database that is built to accept user input of the type of data we&#8217;re trying to collect for datadotgc.ca. It has a slick front and back end that allows administrative access to the collected data.<br />
You can find out more on <a href="http://www.okfn.org/ckan/">their website</a>. </p>
<h3>CKAN&#8217;s API</h3>
<p>In order to utilize the power of CKAN I needed to link it up to Drupal. CKAN has a <a href="http://knowledgeforge.net/ckan/doc/ckan/api.html">powerful and flexible API</a> that I used extensively in the module.</p>
<h3>The Foundation</h3>
<p>Early on in the project I got in touch with the wonderful team at CKAN and they then put me in touch with Sean Burlington from the <a href="http://data.gov.uk">data.gov.uk</a> development team. They had also built their site in Drupal and Seán had lots of information on how they tweaked their CKAN site to work with Drupal. He worked hard to open source some of the work that they had done, and <a href="http://www.practicalweb.co.uk/blog/10/02/24/drupal-module-ckan-integration">released it</a> just in time for us to get started. Seáns module provided the basic API connectivity we needed to get started and was the foundation for our module.</p>
<h3>The Build</h3>
<p>How do you integrate Drupal with the CKAN API? Let&#8217;s start with the basics:</p>
<p>CKAN stores the <a href="http://www.datadotgc.ca/dataset/geogratisnat_hydrography_v100">individual datasets that you see on Datadotgc.ca</a> as &#8216;<em>Packages</em>&#8216;. It became clear that these &#8216;Packages&#8217; could be directly mapped to the standard node architecture in Drupal. To achieve this I created a content type in the module that stored all the data I needed.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p863code25'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p86325"><td class="code" id="p863code25"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Define module-provided node types.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> ckan_node_info<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
  <span style="color: #0000ff;">'ckan'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'name'</span>           <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CKAN Package'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'module'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ckan'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'description'</span>    <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'A package of Open Data.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'has_title'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'title_label'</span>    <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'has_body'</span>       <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'body_label'</span>     <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Package Description'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'min_word_count'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'locked'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">TRUE</span>
    <span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> ckan_create_node<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ckan_data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'title'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$ckan_data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'uid'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'body'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$ckan_data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'promote'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'path'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'dataset/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ckan_data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'type'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ckan'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'comment'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As you can see from the code, the only data elements to be set when a node is created are <em>Title</em>, <em>Body</em> and <em>Path</em>. The body of the node is set to be the name of the CKAN package, which is in fact a simple string: <em>geogratisnat_hydrography_v100</em>.</p>
<p>The more complex CKAN data was not mapped to any CCK fields as you might think, but instead it is pulled from CKAN when the node is loaded. This simplifies the Drupal side of things by ensuring that we don&#8217;t have to keep track of any changes to the structure or contents of the dataset that may happen on the CKAN side.</p>
<p>Here is an example of some package data:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p863code26'); return false;">View Code</a> INI</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p86326"><td class="code" id="p863code26"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>maintainer<span style="">&#93;</span></span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">&gt; Government of Canada, Natural Resources Canada, Centre for Topographic Information <span style="">&#40;</span>Sherbrooke<span style="">&#41;</span></span>
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>name<span style="">&#93;</span></span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">&gt; 1996_population_census_data_canada</span>
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>author<span style="">&#93;</span></span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">&gt; Government of Canada, Natural Resources Canada, Canada Centre for Remote Sensing, GeoAccess Division, The Atlas of Canada</span>
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>url<span style="">&#93;</span></span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">&gt; ftp://ftp.geogratis.gc.ca/atlas/Population_Ecumene_Census/1996/</span>
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>notes<span style="">&#93;</span></span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">&gt; The parts of Canada making up the 1996 Settled Area, <span style="">&#40;</span>or Population Ecumene<span style="">&#41;</span>, represents a selection of the 5984 Census Subdivisions <span style="">&#40;</span>CSD<span style="">&#41;</span> as defined by Statistics Canada for the 1996 Census. The selection process essentially removes those CSDs with very large areas and/or very low populations. Some of British Columbia's CSD boundaries have been further modified to better conform to the distinctive settlement patterns in the Cordilleran regions. The 1996 Settled Area is an attempt to balance the needs of national scale choropleth mapping with the spatial reality that the majority of Canada's land area contains very few people. The Settled Area represents more than 98% of the Canadian population captured in the 1996 Census of Canada.</span>
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>title<span style="">&#93;</span></span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">&gt; 1996 Population <span style="">&#40;</span>Ecumene<span style="">&#41;</span> Census Data, Canada</span>
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>download_url<span style="">&#93;</span></span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">&gt; ftp://ftp.geogratis.gc.ca/atlas/Population_Ecumene_Census/1996/1996.zip</span></pre></td></tr></table></div>

<p>When a node is loaded, the package data is pulled from CKAN and then cached for later use.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p863code27'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p86327"><td class="code" id="p863code27"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Load node-type-specific information
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> ckan_load<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$ckan</span> <span style="color: #339933;">=</span> ckan_ckan<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span> <span style="color: #339933;">=</span> cache_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan:'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">body</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Get the cached data</span>
    <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ckan</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    try <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// Call the API to get the package data</span>
      <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ckan</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPackage</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      drupal_set_message<span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// Cache this package data for later use</span>
    cache_set<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan:'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">body</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ckan</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
    watchdog<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Called CKAN API for '</span><span style="color: #339933;">.</span><span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">body</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' package - ckan_load()'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$node</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Once the CKAN data has been added to the node object it&#8217;s relatively easy to output this data in a node template. I created a template file in my theme called node_ckan.tpl.php and here&#8217;s an example of how I displayed some of the CKAN package data in there:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p863code28'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p86328"><td class="code" id="p863code28"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
 <span style="color: #339933;">&lt;</span>h1 id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page-title&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;title tk-museo-slab&quot;</span><span style="color: #339933;">&gt;&lt;</span> ?php <span style="color: #b1b100;">print</span> <span style="color: #000088;">$title</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;package-name&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">print</span> <span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
 <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;package-link&quot;</span><span style="color: #339933;">&gt;&lt;</span> ?php <span style="color: #b1b100;">print</span> l<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'attributes'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'link'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>You can see from all of the above examples I&#8217;m using a class object called &#8220;<em>ckan</em>&#8221; to store our data. This came from Sean&#8217;s module and is a simple class that provides the connectivity to the CKAN API. Here&#8217;s a brief synopsis of how it works:</p>
<ol>
<li>First I need a way to connect to the API. That&#8217;s relatively straightforward using the <a href="http://php.net/manual/en/book.curl.php">curl libraries in php</a>.

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p863code29'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p86329"><td class="code" id="p863code29"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_init"><span style="color: #990000;">curl_init</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/curl_setopt"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/curl_setopt"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/curl_setopt"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_TIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_exec"><span style="color: #990000;">curl_exec</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$info</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_getinfo"><span style="color: #990000;">curl_getinfo</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/curl_close"><span style="color: #990000;">curl_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

</li>
<li>Now create some functions that allow various parts of the API to be called. Below is an example of two class functions which call the API.

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p863code30'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p86330"><td class="code" id="p863code30"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Get an individual package</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getPackage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$package</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$package</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">transfer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'api/rest/package/'</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/urlencode"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$package</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$package</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> CkanException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Package Load Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$package</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Get a list of all packages</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getPackageList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$list</span> <span style="color: #339933;">=</span>  <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">transfer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'api/rest/package/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$list</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> CkanException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Package List Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$list</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
</ol>
<p>All of these API calls return a JSON object which is then decoded into an object using the PHP function:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p863code31'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p86331"><td class="code" id="p863code31"><pre class="php" style="font-family:monospace;"><a href="http://www.php.net/json_decode"><span style="color: #990000;">json_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Theming</h3>
<p>Once that data has been successfully retrieved and decoded from JSON into something that&#8217;s easier to handle, it needs to be themed. For this I created two theming functions; one for creating an individual list item, the other to create a formatted list of these individual items. I call the theme function whenever I get results from the API, and pass it the results, along with the title I want to appear on the listings page.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p863code32'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p86332"><td class="code" id="p863code32"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Theme the results retrieved from API call</span>
theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_results'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'All Packages'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Theme search results
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> theme_ckan_results<span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #339933;">,</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// Two global variables needed by the pager.</span>
  <span style="color: #666666; font-style: italic;">// Taken from pager_query() in pager.inc</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$pager_page_array</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pager_total</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Grab the 'page' query parameter.</span>
  <span style="color: #666666; font-style: italic;">// Taken from pager_query() in pager.inc</span>
  <span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Convert comma-separated $page to an array, used by other functions.</span>
  <span style="color: #666666; font-style: italic;">// Taken from pager_query() in pager.inc</span>
  <span style="color: #000088;">$pager_page_array</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Generate the data for page the requested and add it to the output.</span>
  <span style="color: #000088;">$items_per_page</span> <span style="color: #339933;">=</span> variable_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_items_per_page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// If there are less results than the specified number of items per page, reset the number of items per page</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$items_per_page</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$items_per_page</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$results</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Initialize pager</span>
  <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// If it's not the first page</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Set the data to start displaying on the correct page</span>
    <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$page</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$items_per_page</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;h1 id=&quot;page-title&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/h1&gt;'</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;h3 class=&quot;resultscount&quot;&gt;Your search returned '</span><span style="color: #339933;">.</span><span style="color: #000088;">$results</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">' records&lt;/h3&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Theme the individual results</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$items_per_page</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span>  theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_item'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Put some magic in the two global variables</span>
  <span style="color: #666666; font-style: italic;">// Based on code in pager_query() in pager.inc</span>
  <span style="color: #000088;">$total_results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$results</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$pager_total</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ceil"><span style="color: #990000;">ceil</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$total_results</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$items_per_page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//ckan_number_of_pages();</span>
  <span style="color: #000088;">$pager_page_array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>
    <a href="http://www.php.net/max"><span style="color: #990000;">max</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <a href="http://www.php.net/min"><span style="color: #990000;">min</span></a><span style="color: #009900;">&#40;</span>
      <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$pager_page_array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$pager_total</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Add the pager to the output.</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pager'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$items_per_page</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Theme individual search items
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> theme_ckan_item<span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// Link the title to the dataset</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;h2&gt;'</span> <span style="color: #339933;">.</span> l<span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dataset/'</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/urlencode"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span>check_plain<span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/h2&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Truncate the notes field</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;p&gt;'</span> <span style="color: #339933;">.</span> truncate_utf8<span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notes</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">250</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wordsafe</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dots</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">// Output any tags	</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tags</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tags</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$items</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> l<span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data/tag/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #000088;">$seperated</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$items</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt; '</span> <span style="color: #339933;">.</span><span style="color: #000088;">$seperated</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>	
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>One thing you need to consider when displaying a list of results is having a pager built in so that you can break the list into bite-sized chunks. This took quite a while to figure out how to do. The problem was that the API call resulted in a lot of data and that resulted in a significant delay loading the page, due to the amount of time to complete the round trip to the API, along with the time taken to render all of that in a pager. CKAN however is very clever. When you call the API and ask for a list of packages, it returns the packages, but it also returns, as a variable, the count of the records your query generated. As well as that you can use the parameters &#8216;<em>offset</em>&#8216; and &#8216;<em>limit</em>&#8216; just like in SQL. What&#8217;s even more clever here is that it still returns the variable that holds the count of the records the query generated, but it also only returns the number of packages determined by the &#8216;<em>offset</em>&#8216; and &#8216;<em>limit</em>&#8216; parameters. </p>
<p>So if an API call to list all packages for a certain tag would normally return 200 records, and you specify a limit of 10 and an offset of 10, the data returned will contain a count of the number of records normally generated by that call, 200, but will <strong>only return 10 packages</strong> in the data, as specified by the offset and limit. This came in extremely useful for the pager as I just passed an offset and limit each time a page was loaded and then cached the returned data.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p863code33'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p86333"><td class="code" id="p863code33"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$ckan</span> <span style="color: #339933;">=</span> ckan_ckan<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$items_per_page</span> <span style="color: #339933;">=</span> variable_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_items_per_page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// If we're in a page, we need to set where to start the list</span>
  <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$page</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$items_per_page</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Set the offset</span>
<span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$start</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Limit to the number of items per page </span>
<span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$items_per_page</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Get the list of tags with their count</span>
try <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">advancedSearch</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'department'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$ministry</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all_fields'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'offset'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'limit'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  drupal_goto<span style="color: #009900;">&#40;</span>variable_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_no_results_page'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sorry'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>Homepage Chart</h3>
<p>There was a requirement for a graph on the homepage the displayed the number of packages attributed to each Government Ministry. The quickest way to do this was using <a href="http://code.google.com/apis/charttools/">Google Chart Tools</a>. It was relatively straightforward to get the data we needed. I did however have to do some funky sorting to get the data in the correct order. I also <a href="http://psychopyko.com/tutorial/how-to-use-google-charts/">found a wonderful tutorial</a> that really helped to clear up some of the label/legend issues I was having.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p863code34'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p86334"><td class="code" id="p863code34"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Function to build a Google Chart
 *
 * @return	  string	HTML code with img tag
 *
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> ckan_chart<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// If there is a cached version of the chart</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span> <span style="color: #339933;">=</span> cache_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan:chart'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    watchdog<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Called Google API to build chart'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Get the list of ministries</span>
    <span style="color: #000088;">$ministries</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> filter_xss<span style="color: #009900;">&#40;</span>variable_get<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan_ministry_list'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Set up our data array</span>
    <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ministries</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$ministry</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$ckan</span> <span style="color: #339933;">=</span> ckan_ckan<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">// Get the list of tags with their count</span>
      try <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ckan</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">advancedSearch</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'department'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$ministry</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'all_fields'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'offset'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'limit'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$results</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #666666; font-style: italic;">// Cache the count to use on the Ministry list page '/ministry'</span>
      cache_set<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan:ministry_'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$ministry</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'_count'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$ministry</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">' ('</span><span style="color: #339933;">.</span> <span style="color: #000088;">$count</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">')'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$count</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// Sort the array in reverse order - most packages first and maintain index association</span>
    <a href="http://www.php.net/arsort"><span style="color: #990000;">arsort</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Return all the keys of the data array - the names of the ministries</span>
    <span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">legend</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_keys"><span style="color: #990000;">array_keys</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Get the range of the chart - highest + a quarter</span>
    <span style="color: #000088;">$range</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/round"><span style="color: #990000;">round</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/current"><span style="color: #990000;">current</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color:#800080;">1.25</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Grid spacing  100/MaxRange*IntervalAmount</span>
    <span style="color: #000088;">$grid</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">/</span><span style="color: #000088;">$range</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Chart size, must be less than 30k pixels</span>
    <span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">size</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'590'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'380'</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Create query</span>
    <span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span> <span style="color: #339933;">=</span>
      <span style="color: #0000ff;">'cht=bhg&amp;'</span><span style="color: #339933;">.</span>	<span style="color: #666666; font-style: italic;">// Type</span>
      <span style="color: #0000ff;">'chd=t:'</span><span style="color: #339933;">.</span><a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">.</span>	<span style="color: #666666; font-style: italic;">// Data</span>
      <span style="color: #0000ff;">'chs='</span><span style="color: #339933;">.</span><span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">size</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'x'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">size</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">.</span>	<span style="color: #666666; font-style: italic;">// Size</span>
      <span style="color: #0000ff;">'chco=cc0000&amp;'</span><span style="color: #339933;">.</span>	<span style="color: #666666; font-style: italic;">// Color ( Remove # from string )</span>
      <span style="color: #0000ff;">'chxt=x,y&amp;'</span><span style="color: #339933;">.</span>	<span style="color: #666666; font-style: italic;">// X,Y axis labels</span>
      <span style="color: #0000ff;">'chxr=0,0,'</span><span style="color: #339933;">.</span><span style="color: #000088;">$range</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">.</span> <span style="color: #666666; font-style: italic;">// Range</span>
      <span style="color: #0000ff;">'chxs=1,000000,13|0,000000,13&amp;'</span><span style="color: #339933;">.</span> 	<span style="color: #666666; font-style: italic;">// Axis colors and font size</span>
      <span style="color: #0000ff;">'chg='</span><span style="color: #339933;">.</span><span style="color: #000088;">$grid</span><span style="color: #339933;">.</span><span style="color: #0000ff;">',0,5,5&amp;'</span><span style="color: #339933;">.</span> <span style="color: #666666; font-style: italic;">// Grid verticalgridlines, horizontalgridlines, linesize, gapsize</span>
      <span style="color: #0000ff;">'chds=0,'</span><span style="color: #339933;">.</span><span style="color: #000088;">$range</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">.</span>	<span style="color: #666666; font-style: italic;">// Scale</span>
      <span style="color: #0000ff;">'chma=0,0,0,0&amp;'</span><span style="color: #339933;">.</span> <span style="color: #666666; font-style: italic;">//left_margin, right_margin, top_margin, bottom_margin| legend_width, legend_height</span>
      <span style="color: #0000ff;">'chbh=13,0,2&amp;'</span><span style="color: #339933;">.</span>	<span style="color: #666666; font-style: italic;">// bar_width_or_scale, space_between_bars, space_between_groups</span>
      <span style="color: #0000ff;">'chxl=1:|'</span><span style="color: #339933;">.</span><a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array_reverse"><span style="color: #990000;">array_reverse</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">legend</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//|Jan|Feb|Mar|Apr|May'</span>
&nbsp;
    <span style="color: #000088;">$api_path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://chart.apis.google.com/chart?'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/sprintf"><span style="color: #990000;">sprintf</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;img src=&quot;%s&quot; alt=&quot;%s&quot; style=&quot;width:%spx;height:%spx;&quot; /&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$api_path</span><span style="color: #339933;">.</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Who\'s Sharing'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">size</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$chart</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">size</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      cache_set<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ckan:chart'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_ckan'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>	
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$image</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>So that&#8217;s a brief(not-so) overview of some of the fundamentals of how I integrated Drupal with CKAN and was able to create nodes and listings directly from API calls. </p>
<p><a href="/2010/06/datadotgc-ca-a-drupal-case-study-part-2/">In my next post I&#8217;ll cover some very important areas</a> of the module development such as:</p>
<ul>
<li>Caching</li>
<li>Tag cloud creation</li>
<li>Using the CKAN Search API for all lists</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.raisedeyebrow.com/2010/04/datadotgc-ca-a-drupal-case-study/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rewrite a Views query</title>
		<link>http://blog.raisedeyebrow.com/2010/04/rewrite-a-views-query/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rewrite-a-views-query</link>
		<comments>http://blog.raisedeyebrow.com/2010/04/rewrite-a-views-query/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 19:20:51 +0000</pubDate>
		<dc:creator>Colin Calnan</dc:creator>
				<category><![CDATA[Code and Coding]]></category>
		<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Views]]></category>

		<guid isPermaLink="false">http://blog.raisedeyebrow.com/?p=845</guid>
		<description><![CDATA[Recently, due to Views lack of ability to OR it&#8217;s filters together and due to some serious constraints in relation to arguments and relationships, I found myself needing to figure out how to rewrite the SQL of a Drupal view so that I could get the records that I needed.
It seems like there are two [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, due to Views lack of ability to OR it&#8217;s filters together and due to some serious constraints in relation to arguments and relationships, I found myself needing to figure out how to rewrite the SQL of a Drupal view so that I could get the records that I needed.</p>
<p>It seems like there are two ways to do this. You can either rewrite the SQL directly, or try to hack the query object that views provides.</p>
<p>A quick Google search and <a href="http://drupal.org/node/409808">I ended up on Drupal.org</a></p>
<p>Which then led me to the <a href="http://views.doc.logrus.com/group__views__hooks.html ">Views documentation</a></p>
<p>From here I was able to deduce that the</p>
<pre>hook_views_pre_execute()</pre>
<p>hook was what I needed.</p>
<p>I created my module and added the hook:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p845code41'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84541"><td class="code" id="p845code41"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Implementation of hook_views_pre_execute()
 *
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> other_views_pre_execute<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$view</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// If it's my view</span>
    <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'my_view'</span><span style="color: #339933;">:</span>
      <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_display</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// If it's the block on the author page</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'block_5'</span><span style="color: #339933;">:</span>
	  <span style="color: #666666; font-style: italic;">// Set the extra argument</span>
	  <span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">build_info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query_args'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">build_info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query_args'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	  <span style="color: #666666; font-style: italic;">// Rewrite the query</span>
	  <span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">build_info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT ... &quot;</span><span style="color: #339933;">;</span>
	  <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Lets step through this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p845code42'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84542"><td class="code" id="p845code42"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> other_views_pre_execute<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$view</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></td></tr></table></div>

<p>We need to make sure the word hook is replaced with the name of our module, in this case it&#8217;s called &#8216;other&#8217;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p845code43'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84543"><td class="code" id="p845code43"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// If it's my view</span>
  <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'my_view'</span><span style="color: #339933;">:</span></pre></td></tr></table></div>

<p>Each view is represented by a unique name. We need to modify the query for a certain view, not all of them, in this case the view is called &#8216;my_view&#8217;.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p845code44'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84544"><td class="code" id="p845code44"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_display</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// If it's the block on the author page</span>
  <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'block_5'</span><span style="color: #339933;">:</span></pre></td></tr></table></div>

<p>Views can have multiple displays, such as blocks, pages and attachments. In this case we want to target the block display with the name/id &#8216;block_5&#8242;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p845code45'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84545"><td class="code" id="p845code45"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Set the extra argument</span>
<span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">build_info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query_args'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">build_info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query_args'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Rewrite the query</span>
<span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">build_info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT ... &quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>In this case our query is going to have an extra argument added to the query. These arguments are an array $view-&gt;build_info['query_args']. They appear in the form &#8216;%s&#8217; and &#8216;%d&#8217; in the query text, like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p845code46'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84546"><td class="code" id="p845code46"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #66cc66;">&#40;</span>node<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">status</span> <span style="color: #66cc66;">&lt;&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #66cc66;">&#40;</span>node<span style="color: #66cc66;">.</span>type <span style="color: #993333; font-weight: bold;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'%s'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>node_node_data_field_publication_centre_authors<span style="color: #66cc66;">.</span>title <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'%s'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #66cc66;">&#40;</span>node_node_data_field_publication_first_author<span style="color: #66cc66;">.</span>title <span style="color: #66cc66;">=</span><span style="color: #ff0000;">'%s'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>In this case the first &#8216;%s&#8217; = $view->build_info['query_args'][0], the second one = $view->build_info['query_args'][1] and so on.</p>
<p>And that&#8217;s it. Your query is rewritten. One thing to watch our for, do not add any extra fields in the SELECT statement, this can cause all sorts of crazy problems.</p>
<p>The alternative to using the pre_execute hook is to use the <a href="http://views.doc.logrus.com/group__views__hooks.html#gf4d538493930fe0fa0ce6fb3bf42c156">query_alter hook</a>.</p>
<p>This seems a lot trickier and even <a href="http://www.nicklewis.org/hook-views-query-alter-how-programatically-alter-views-queries#comment-52901">Earl Miles himself hates this hook</a>, so I suggest staying away from it, but if you&#8217;re interested in what it looks like here&#8217;s a quick Krumo screenshot of what it looks like. This was achieved using the devel module along with the kpr() command. So</p>
<pre>kpr($view->query); 

<div id="attachment_846" class="wp-caption aligncenter" style="width: 377px"><a href="http://blog.raisedeyebrow.com/wp-content/uploads/2010/04/views_query_krumo.gif"><img class="size-full wp-image-846" title="Anatomy of a View Query" src="http://blog.raisedeyebrow.com/wp-content/uploads/2010/04/views_query_krumo.gif" alt="Anatomy of a View Query" width="367" height="373" /></a><p class="wp-caption-text">Anatomy of a View Query</p></div></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.raisedeyebrow.com/2010/04/rewrite-a-views-query/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Passing a querystring to FormAPI redirect</title>
		<link>http://blog.raisedeyebrow.com/2010/03/passing-a-querystring-to-formapi-redirect/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=passing-a-querystring-to-formapi-redirect</link>
		<comments>http://blog.raisedeyebrow.com/2010/03/passing-a-querystring-to-formapi-redirect/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 21:36:10 +0000</pubDate>
		<dc:creator>Colin Calnan</dc:creator>
				<category><![CDATA[Code and Coding]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[FormAPI]]></category>

		<guid isPermaLink="false">http://blog.raisedeyebrow.com/?p=840</guid>
		<description><![CDATA[Here&#8217;s a really quick and useful trick to know.
Sometimes you might want your form to redirect to somewhere and pass a few bits of information in the querystring, so that you can do something when you get there.
For example, I needed a recent form to redirect depending on which checkboxes were checked to build a [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a really quick and useful trick to know.</p>
<p>Sometimes you might want your form to redirect to somewhere and pass a few bits of information in the querystring, so that you can do something when you get there.</p>
<p>For example, I needed a recent form to redirect depending on which checkboxes were checked to build a certain URL:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p840code48'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84048"><td class="code" id="p840code48"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form_state</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'values'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filters'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'open'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	<span style="color: #000088;">$query</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'o=1'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> 
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form_state</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'values'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filters'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'down'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	<span style="color: #000088;">$query</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'d=1'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$form_state</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'redirect'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'data/search/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$keyword</span><span style="color: #339933;">,</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>If &#8220;open&#8221; checkbox is checked, it will redirect to &#8220;data/search/keyword?o=1&#8243;. I then get the value of this using $_GET['o']. Simple eh?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.raisedeyebrow.com/2010/03/passing-a-querystring-to-formapi-redirect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Socially Conscious Geeks Unite!</title>
		<link>http://blog.raisedeyebrow.com/2010/03/socially-conscious-geeks-unite/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=socially-conscious-geeks-unite</link>
		<comments>http://blog.raisedeyebrow.com/2010/03/socially-conscious-geeks-unite/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 16:52:01 +0000</pubDate>
		<dc:creator>Lauren Bacon</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Nonprofit Tech]]></category>
		<category><![CDATA[Workshops & Events]]></category>

		<guid isPermaLink="false">http://blog.raisedeyebrow.com/?p=835</guid>
		<description><![CDATA[I&#8217;m writing this from Austin, TX, where I&#8217;m participating in one of the geek world&#8217;s biggest and best-loved festivals, South by Southwest Interactive (SXSWi for short). Yesterday afternoon, I had the great pleasure of co-facilitating a session with Leif Utne, VP of Community at Zanby, that was a group discussion on how design &#38; tech [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.raisedeyebrow.com/wp-content/uploads/2010/03/thesociallyconsciousgeek.jpg"><img class="alignleft size-full wp-image-837" title="thesociallyconsciousgeek" src="http://blog.raisedeyebrow.com/wp-content/uploads/2010/03/thesociallyconsciousgeek.jpg" alt="" width="320" height="320" /></a>I&#8217;m writing this from Austin, TX, where I&#8217;m participating in one of the geek world&#8217;s biggest and best-loved festivals, <a href="http://www.sxsw.com/interactive">South by Southwest Interactive</a> (SXSWi for short). Yesterday afternoon, I had the great pleasure of co-facilitating a session with <a href="http://leifutne.wordpress.com/">Leif Utne</a>, VP of Community at <a href="http://zanby.com/">Zanby</a>, that was a group discussion on how design &amp; tech geeks can make the world a better place while making a living.</p>
<p>When we were planning the session, Leif suggested we use a format I wasn&#8217;t familiar with &#8212; the <a href="http://www.kstoolkit.org/Samoan+Circle">Samoan Circle</a>, a modified fishbowl process that encourages listening and made room for many of the attendees to come forward and speak. The chairs in the room were arranged in the round, and we pulled four chairs into the middle of the room, facing each other, so that everyone could see and hear the folks who were talking.</p>
<p>The theme of the session was &#8220;<a href="http://my.sxsw.com/events/event/794">Socially Conscious Geek: making money while doing good</a>,&#8221; and we provided some framing questions, but we knew that whoever showed up would have their own questions and goals for the discussion, so we tried to move quickly beyond our introductions and dive into the conversation proper.</p>
<p>I&#8217;m so glad we did, because as soon as we opened it up to the room, the conversation went in very interesting directions. Some of the themes that emerged were:</p>
<ul>
<li>Recruiting challenges for nonprofits: Someone asked how nonprofits can attract staff when the salaries are generally lower than they are in the corporate sector. Some great responses to this question emerged, including:
<ul>
<li>Explore what gets geeks interested, and offer up incentives that matter to them</li>
<li>Sell the lifestyle &amp; &#8220;sleep better at night&#8221; benefits</li>
<li>Offer other benefits that provide competitive advantage with corporate positions, e.g. keep work hours reasonable, paid volunteer time, etc.</li>
<li>Someone mentioned that in the US, if you work for nonprofit organizations for 10 years after college, your <a href="http://www.ncnonprofits.org/advocacy/loanforgiveness.asp">outstanding student loans are forgiven</a>. Given the size of the average student loan these days, that could provide a tangible financial benefit in the tens, or even hundreds of thousands of dollars.</li>
<li>Recognize that nonprofits can offer more opportunities for leadership &amp; effecting change within the organization, because nonprofits often have leaner &amp; more democratic structures. (I want to point out that this is definitely not always the case, though I do think it&#8217;s a valid point. However, I&#8217;ve seen some highly inefficient nonprofit organizations in my time.)</li>
</ul>
</li>
<li>There was some great discussion of how our definitions of sustainability must include financial sustainability; this is true for both for-profit and not-for-profit organizations. We need to both make money and do good; neither can be sacrificed. Some models put forward for this included:
<ul>
<li>Businesses can build charitable giving into their modus operandi, i.e. give x% of pre-tax profits to a particular cause or organization.</li>
<li>Design &amp; tech agencies can offer discounts to nonprofit clients &amp; stay profitable by engaging high-profit corporate clients.</li>
<li>Social enterprise models, e.g. nonprofits creating products &amp; services people are willing to pay for.</li>
<li>Seed funding from progressive coalitions</li>
</ul>
</li>
<li>We also heard a number of people ask how we can collaborate better across movements and sectors &#8211; there is a real hunger for cross-pollination of ideas and learning from one another&#8217;s successes and failures.</li>
<li>One women shared her story of working at a large, multinational corporation, feeling somewhat discouraged by said corporation&#8217;s lack of a formal social responsibility mandate, and responding by starting interest groups within her company. This has had the effect of both raising the profile of various causes, but also concrete changes in the business such as influencing purchasing decisions.</li>
<li>Someone said they would love to see a crowdsourcing app that could leverage companies&#8217; internal technical skills &amp; resources and connect &amp; share them with nonprofits who need them.</li>
</ul>
<p>Those were my notes, but there&#8217;s plenty more available on Twitter &#8212; attendees tweeted their session notes using the hashtag <a href="http://search.twitter.com/search?q=%23scgeek">#scgeek</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.raisedeyebrow.com/2010/03/socially-conscious-geeks-unite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Socially Conscious Geek: Makin’ Money While Doin’ Good</title>
		<link>http://blog.raisedeyebrow.com/2010/01/socially-conscious-geek-makin%e2%80%99-money-while-doin%e2%80%99-good/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=socially-conscious-geek-makin%25e2%2580%2599-money-while-doin%25e2%2580%2599-good</link>
		<comments>http://blog.raisedeyebrow.com/2010/01/socially-conscious-geek-makin%e2%80%99-money-while-doin%e2%80%99-good/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 15:42:25 +0000</pubDate>
		<dc:creator>Lauren Bacon</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Nonprofit Tech]]></category>
		<category><![CDATA[Raised Eyebrow]]></category>
		<category><![CDATA[The Social Web]]></category>
		<category><![CDATA[Workshops & Events]]></category>

		<guid isPermaLink="false">http://blog.raisedeyebrow.com/?p=804</guid>
		<description><![CDATA[Two years ago, Emira &#38; I went to South by Southwest (AKA SXSW) for the first time, and presented a panel called “Boss Lady” that featured tips for online business owners from several of the savviest women entrepreneurs we know: Vickie Howell, Jenny Hart &#38; Alex Beauchamp, all of whom appear in the pages of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-816" title="sxswi2010" src="http://blog.raisedeyebrow.com/wp-content/uploads/2010/01/sxswi2010.gif" alt="sxswi2010" width="181" height="272" />Two years ago, Emira &amp; I went to <a href="http://sxsw.com">South by Southwest</a> (AKA SXSW) for the first time, and presented a panel called “<a href="http://2007.sxsw.com/interactive/programming/panels/?action=show&amp;id=IAP060126">Boss Lady</a>” that featured tips for online business owners from several of the savviest women entrepreneurs we know: <a href="http://www.vickiehowell.com">Vickie Howell</a>, <a href="http://www.jennyhart.net/">Jenny Hart</a> &amp; <a href="http://girlatplay.com/">Alex Beauchamp</a>, all of whom appear in the pages of our book, <em><a href="http://laurenandemira.com">The Boss of You</a>. </em>We had such a good time that we knew we wanted to go back as soon as humanly possible, though last year we were too busy getting our book out the door to attend the conference.</p>
<p>But this year we’re back, this time with a panel that we hope will prove helpful to geeks of both the design and techie varieties – both camps are in full force at <a href="http://sxsw.com/interactive/">SXSW’s Interactive conference</a>, which is a pure, 24/7, all-out geekfest – who are looking to bring their values into their paid work, whether it’s by learning to work with clients in the nonprofit sector, creating apps that help mission-driven organizations work more effectively, or infusing some environmental or social-justice savvy into their workplaces. The panel’s called “<a href="http://panelpicker.sxsw.com/ideas/view/3573">Socially Conscious Geek: Makin’ Money While Doin’ Good</a>”, and it takes place Saturday, March 13<sup>th</sup>.</p>
<p>The topic was inspired by a topic our friend Noah Scalin (of <a href="http://skulladay.blogspot.com/">Skull-A-Day</a> and <a href="http://www.alrdesign.com/">Another Limited Rebellion</a> fame) spoke about at the 2009 <a href="http://www.howconference.com">HOW Conference</a>. His focus was more on graphic design, since that’s his area of expertise, but when I asked him about riffing on his ideas for an interactive design audience, he shared his materials with me with typical generosity. (This is a guy who lives and breathes a DIY, share-and-share-alike mentality that a lot of designers could learn from. But that’s a topic for another day.)</p>
<p>This time I’ll be attending the conference solo, while Emira spends some time with her new baby; my co-facilitator for the session is <a href="http://leifutne.wordpress.com/">Leif Utne</a>, a friend and colleague who works for <a href="http://zanby.com/">Zanby</a>, a software company that specializes in supporting online social communities for change. Leif’s background includes a stint as the publisher of Worldchanging.org, and lots of experience building online communities; he&#8217;s also a journalist, activist and social entrepreneur.  Zanby is used to support <a href="http://www.theuptake.org">The UpTake</a>, a web video community that among other things was heavily involved in documenting the RNC and DNC prior to the 2008 election, and was also engaged in citizen vote monitoring during the election. He brings both amazing facilitation skills as well as a solid understanding of how businesses and nonprofits can work together in mutually beneficial ways.</p>
<p>We’ll be conducting our session in a highly interactive, inclusive format called a Core Conversation: Leif and I will be kick-starting the discussion and planting some seeds, but the idea is that whoever shows up will have a chance to step forward and contribute questions and ideas – so I’m really excited to see how it develops.</p>
<p>We’re hoping to address questions like:</p>
<ul>
<li> What is a socially conscious geek?</li>
<li> How can I specialize in socially conscious work and earn a living wage?</li>
<li> What are some of the unique opportunities and challenges of specializing in socially conscious work?</li>
<li> What is the difference between non-profit and no-profit clients?</li>
<li> How do I make the transition from corporate work to working with non-profit and/or mission-driven clients?</li>
<li> What is the “triple bottom line” approach to business?</li>
<li> What are some examples of alternative business models that are emerging among socially conscious geeks?</li>
<li> How is socially conscious work different than “green” work?</li>
<li> What are some examples of clients I might be able to work with as a socially conscious geek?</li>
<li> How should I market myself to values-driven clients? Is it different from marketing to corporate clients?</li>
</ul>
<p>Ultimately, though, the decisions about what we cover will rest with whoever shows up. So please help us spread the word – and if you’ll be at SXSW, we’d love to see you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.raisedeyebrow.com/2010/01/socially-conscious-geek-makin%e2%80%99-money-while-doin%e2%80%99-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
