<?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>I am Ad Taylor &#187; Perch</title>
	<atom:link href="http://www.iamadtaylor.com/tag/perch/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iamadtaylor.com</link>
	<description>The portfolio and blog of Ad Taylor</description>
	<lastBuildDate>Thu, 20 May 2010 22:49:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Perch Admin collapsable menu</title>
		<link>http://www.iamadtaylor.com/perch-admin-collapsable-menu/</link>
		<comments>http://www.iamadtaylor.com/perch-admin-collapsable-menu/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 09:20:22 +0000</pubDate>
		<dc:creator>Ad Taylor</dc:creator>
				<category><![CDATA[shorts]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Perch]]></category>

		<guid isPermaLink="false">http://www.iamadtaylor.com/?p=225</guid>
		<description><![CDATA[<p>My only gripe with the Perch admin interface was the landing page or more specifically the huge list of regions, I was finding that it looked daunting to new editors. This is something that Perch are looking at but I wanted a solution for the meantime. Unfortunately the solution is horribly hacky, involving altering the perch.js file.</p>]]></description>
			<content:encoded><![CDATA[<p>I <strong>promise</strong> that this will be my last post about <span class="vcard"><a href="http://www.grabaperch.com" class="url org">Perch</a></span>, I am starting to look somewhat obsessed.
</p>
<p>This hack was born out of necessity as I found that the admin <abbr title="User Interface">UI</abbr> on large <span class="vcard"><a href="http://www.grabaperch.com" class="url org">Perch</a></span> sites looked daunting to new editors.  Though the <abbr title="User Interface">UI</abbr> is beautiful and clean I was finding the lists would be endless and the editor could not find the page, let alone the region. This is something that Perch are looking at but I wanted a solution for the meantime. Unfortunately the solution is horribly hacky, involving altering the perch.js file.</p>
<h3>How to</h3>
<p>Add the following to the bottom of the perch.js file (found in the <code>your-perch-folder/assets/js/perch.js</code>)</p>
<pre name="code" class="javascript">
function pageTidy () {
	if($('td.page').length > 1) {
		resetToTidy();
		$('.page span').css({ cursor: 'pointer' });
		$('.page span').click(function() {
			resetToTidy();
			$(this).parent('td').parent('tr').addClass('currentPage');
			$('.currentPage').children('td').show();
			$('.currentPage').nextAll().each(function(index) {
				if($(this).css('display') == 'table-row'){
					return false;
				}
				$(this).show();
			});
		});
	}

}
function resetToTidy() {
	$('.d  tbody tr').hide();
	$('.shared').parent('tr').show();
	$('.shared').parent('tr').nextAll().each(function(index) {
		if($(this).children('td').hasClass('page')) {
			return false;
		}
		$(this).show();
	});
	$('.d tr').removeClass('currentPage');
	$('.page').parent('tr').show();
	$('.page').siblings('td').hide();
}
</pre>
<p>Then add <code>pageTidy();</code> to the init function. So it would now look like:</p>
<pre name="code" class="javascript">
var init	= function() {
		$('body').addClass('js');
		enhanceCSS();
		initPopups();
		hideMessages();
		pageTidy();
	};
</pre>
<h3>Warning</h3>
<p>Use at your own risk! I have found it seems to work happily on my project but I can&#8217;t imagine that it&#8217;s a good idea to be hacking away at core files. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.iamadtaylor.com/perch-admin-collapsable-menu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Archive Extractor &#8211; A Perch Hack / Plugin</title>
		<link>http://www.iamadtaylor.com/archive-extractor-a-perch-plugin/</link>
		<comments>http://www.iamadtaylor.com/archive-extractor-a-perch-plugin/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 10:29:57 +0000</pubDate>
		<dc:creator>Ad Taylor</dc:creator>
				<category><![CDATA[features]]></category>
		<category><![CDATA[Perch]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.iamadtaylor.com/?p=148</guid>
		<description><![CDATA[A plugin to help with the extraction of content itmes from the Perch database.]]></description>
			<content:encoded><![CDATA[<h1>Archive Extractor &#8211; A Perch Hack / Plugin</h1>
<div id="text-wrap">
<p class="edit note"><strong>Edit :</strong> Changes made as per Drew&#8217;s advice. Now deals with &#8217;shared&#8217; content and custom table prefix.</p>
<p>For sometime now I have been meaning to post this little hack I came up with — however I completely forgot. This is a hack for the <strong>brilliant</strong> &#8216;little&#8217; <abbr  title="Content managment system">CMS </abbr>, <a href="http://grabaperch.com/" title="Perch CMS">Perch</a> .<br/> It was made through necessity as I <strong>wanted</strong> to use Perch but I <strong>needed</strong> to be able to have news items from other pages on the front page. To my surprise it was nice and easy, and although I&#8217;m sure it will be inefficient, it seems pretty fast.</p>
<p>It is an incredibly simple plugin that pulls the JSON out of the Perch database and returns it. It doesn&#8217;t try to do anything else — no formatting, no nothing — just the way I like it.</p>
<p class="note"><strong>Standard disclaimer :</strong> I am not a server-side kinda guy, I can not take responsibility for anything this plugin does to your installation of Perch, server security or general happiness. That said, I can&#8217;t see how these lazy few lines of code could screw up much.</p>
<h2 class="installation">Installation</h2>
<p>Download the file and put it in your Perch &#8220;plugins&#8221; folder. This isn&#8217;t mandatory for it to work but just seems like a logical place to put it. Watch out when you next need to update Perch — Back up!!</p>
<h2 class="usage">Usage</h2>
<p>You must include the file at the top of the page you wish to use Archive Extractor. If your Perch directory is called &#8220;perch&#8221; then the include could be something like this:
</p>
<pre name="code" class="php">
	 include('perch/plugins/archiveExtractor/archiveExtractor.php');
</pre>
<p>To use just call the function with the 2 variables, the Perch Content name (e.g &#8220;News Item&#8221;) and the path to the page it is on (e.g &#8220;/news/index.php&#8221;). With the data returned you can iterate through the items and pull from it the data you want. <br/> Maybe best seen as an example:</p>
<pre name="code" class="php">
	// Call function with variables.
	$newsArchive = archiveExtractor('News Item','/news/index.php');
	// Check to see if there are any results
	if($newsArchive) {
		$limit = count($newsArchive);
		// Loop through all results
		for ($i=0; $i < $limit; $i++) {
			// In the example the word 'title' refers to the id of a content type
			// from the 'News Item' content template
			echo '
<li>
<h5>'.$newsArchive[$i]->title.' Trip</h5>

 on '.$newsArchive[$i]->information.'.</li>

';
		}
	}
</pre>
<p>If you want to extract data from shared regions, simply leave out the content path. It took me a while to understand the point of this (as this was recommended by <a href="http://grabaperch.com" class="vcard fn url">Drew</a>) but obviously it would be handy if you only wanted to extract part of the data (i.e. title and date).</p>
<pre name="code" class="php">
$newsArchive = archiveExtractor('News Item');
</pre>
<p><a href="/resources/archiveExtractor.zip" title="Download Archive Extrator" ><span class="download">Download</span></a><br />
<a href="#" title="Click to see plugin code" class="show-code">Click to view code</a></p>
<div class="clear"></div>
<div class="code-hide">
<pre name="code" class="php">
/*
	Archive Extractor - A Perch Hack
	By Ad Taylor - http://www.iamadtaylor.com
	For usage see :
	Creative Commons Attribution-Share Alike 2.0 UK: England &#038; Wales Licence
*/

function archiveExtractor($contentKey,$contentPage = '*')
{
	$query = queryDB($contentKey,$contentPage,$limit);
	if ($query) {
		foreach ($query as $key => $value) {
			$json = $value;
		}

		return PerchUtil::json_safe_decode($json);
	} else {
		return NULL;
	}

}

function queryDB($contentKey,$contentPage) {

	require_once $_SERVER['DOCUMENT_ROOT'].'/edit/config/config.php';

	$link = @mysql_connect(PERCH_DB_SERVER, PERCH_DB_USERNAME, PERCH_DB_PASSWORD);

	if (!$link) {
		return NULL;
	}
	else {
		mysql_select_db(PERCH_DB_DATABASE,$link);
		$sql = "SELECT `contentJSON` FROM `".PERCH_DB_PREFIX."contentItems` WHERE `contentKey` LIKE '$contentKey' AND `contentPage` LIKE CONVERT(_utf8 '$contentPage' USING latin1) OR '*' COLLATE latin1_swedish_ci";
		$result = mysql_query($sql, $link);
		return mysql_fetch_assoc($result);
		mysql_close($link);

	}
}</pre>
</div>
</div>
<p><!-- #text-wrap --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iamadtaylor.com/archive-extractor-a-perch-plugin/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A Perch Textmate bundle</title>
		<link>http://www.iamadtaylor.com/a-perch-textmate-bundle/</link>
		<comments>http://www.iamadtaylor.com/a-perch-textmate-bundle/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 11:49:47 +0000</pubDate>
		<dc:creator>Ad Taylor</dc:creator>
				<category><![CDATA[shorts]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[Perch]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://www.iamadtaylor.com/?p=150</guid>
		<description><![CDATA[A Textmate bundle to speed up development on Perch templates.]]></description>
			<content:encoded><![CDATA[<p>I thought I would host this up for anyone who is using Perch and Textmate, its not much but it could save someone else the arduous task of making it themselves.</p>
<p>You can download it from <a href="http://iamadtaylor.com/resources/Perch.tmbundle" title="Textmate Perch bundle">here</a> (probably right click &#8217;save as&#8217;).</p>
<p>The bundle doesn&#8217;t do much more than speed up your workflow on Perch sites, its usage is pretty easy:</p>
<ul>
<li>perchc+tab = <code>perch_content('Content');</code></li>
<li>percht+tab = inserts type:text</li>
<li>perchta+tab = inserts type:textarea</li>
<li>perchd+tab = inserts type:date</li>
<li>perchi+tab = inserts type:image</li>
<li>perchf+tab = inserts type:file</li>
</ul>
<p>Keep it simple stupid.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iamadtaylor.com/a-perch-textmate-bundle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

