<?xml version="1.0"?>

	<rss version="2.0">
	  <channel>
		<title>andrewembler.com</title>
		<link>http://andrewembler.com/feed</link>
		<description>The written words and audio of Andrew Embler, on topics such as concrete5, the web, personal computing, music and art.</description> 

	
			<item>
			  <title>Improving the Performance of Zend Cache</title>
			  <link>http://andrewembler.com/web/improving-the-performance-of-zend-cache/</link>
			  <description>
			  <![CDATA[
				<p>We just upgraded concrete5.org to a new version of concrete5, and were noticing a disturbing drop in performance. This new version of concrete5 uses several more libraries from the widely used Zend Framework, and we thought their addition was the culprit. The libraries? Zend Locale and Zend Cache. These libraries provide some great functionality, but Zend's libraries can require more memory than home-grown solutions. We assumed this was the case.</p>
<p>Looking into the processes on our server, we discovered that our httpd threads were running with very high CPU usage. It wasn't out of the ordinary for an average httpd thread to hit 80-100% usage. MySQL usage wasn't terribly high. Unfortunately, the problem wasn't easily reproduced. Certain pages loaded quickly at certain times. At other times they lagged for an eternity.</p>
<p>However, I found the answer when digging into the Zend Cache internals. It turns out that Zend Cache helpfully includes an option for garbage collection and periodic cache cleaning.</p>
<p><strong>automatic_cleaning_factor</strong></p>
<p><strong><span style="font-weight: normal;">According to Zend, this option "tune(s) the automatic cleaning process (garbage collector): 0 means no automatic cache cleaning, 1 means systematic cache cleaning and x &gt; 1 means automatic random cleaning 1 times in x write operations."</span></strong></p>
<p><strong><span style="font-weight: normal;">Sadly, this default setting was wreaking havoc with our highly trafficked server. So, I disabled it, with the following line of code in our config/site.php:</span></strong></p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'CACHE_FRONTEND_OPTIONS'</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><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'automatic_cleaning_factor'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li></ol></pre></div><p>The result? Average httpd thread has dropped from 50-100% down to 6-7%. I would encourage anyone running the default Zehd file cache adapter to check out this option. The improvement in speed has been dramatic.&nbsp;</p><p class="byline">Andrew Embler is jazzed about the improvement of speed in concrete 5.4.</p>				<br/><br/>
				<a href="http://andrewembler.com/web/improving-the-performance-of-zend-cache/">Comment on this at andrewembler.com</a>
			  ]]>
			  </description>
			  <pubDate>Thu, 04 Mar 2010 17:35:00 EST</pubDate>
			</item>
		
			<item>
			  <title>Building a Custom RSS Feed Using Single Pages, Controllers, and the Page List class.</title>
			  <link>http://andrewembler.com/concrete5/building-a-custom-rss-feed/</link>
			  <description>
			  <![CDATA[
				<div class="tweetmeme_button" style="float: right; margin-left: 15px; margin-right: 5px;">
<iframe src="http://api.tweetmeme.com/button.js?url=http%3A%2F%2Fandrewembler.com%2Ffeed%2F&source=&style=normal&service=default" height="61" width="50" frameborder="0" scrolling="no">
</iframe>
</div><p>While the concrete5 page list block provides an RSS feed option, it isn't perfect. Its URL is a little unwieldy, and changes to the page list block may interfere with that RSS feed working. Additionally, I had some filtering requirements for my RSS feed that the page list couldn't quite provide. Those problems are on our radar, but I needed a fix now!</p>
<p>So what did I do? I made a custom single page and controller, at the /feed/ URL. Here are the components:</p>
<h2>/controllers/feed.php</h2><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><span style="color: #999999; font-weight: bold;">&lt;?</span>
&nbsp;
<span style="color: #999999; font-weight: bold;">class</span> FeedController <span style="color: #999999; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
   <span style="color: #999999; font-weight: bold;">public</span> <span style="color: #999999; font-weight: bold;">function</span> view<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      Loader<span style="color: #339933;">::</span><span style="color: #00FF00;">model</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'page_list'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'Content-type: text/xml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #4444ff;">&quot;&lt;?xml version=<span style="color: #000099; font-weight: bold;">\&quot;</span>1.0<span style="color: #000099; font-weight: bold;">\&quot;</span>?&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #999999; font-weight: bold;">?&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>rss version<span style="color: #339933;">=</span><span style="color: #4444ff;">&quot;2.0&quot;</span><span style="color: #339933;">&gt;</span>
     <span style="color: #339933;">&lt;</span>channel<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>andrewembler<span style="color: #339933;">.</span>com<span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>link<span style="color: #339933;">&gt;</span><span style="color: #999999; font-weight: bold;">&lt;?=</span>BASE_URL <span style="color: #339933;">.</span> DIR_REL<span style="color: #999999; font-weight: bold;">?&gt;</span><span style="color: #339933;">/</span>feed<span style="color: #339933;">&lt;/</span>link<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>description<span style="color: #339933;">&gt;</span>The written words and audio of Andrew Embler<span style="color: #339933;">,</span> 
      on topics such <span style="color: #b1b100;">as</span> concrete5<span style="color: #339933;">,</span> the web<span style="color: #339933;">,</span> personal computing<span style="color: #339933;">,</span> music and art<span style="color: #339933;">.&lt;/</span>description<span style="color: #339933;">&gt;</span> 
&nbsp;
   <span style="color: #999999; font-weight: bold;">&lt;?</span>
      <span style="color: #6666FF;">$pl</span> <span style="color: #339933;">=</span> <span style="color: #999999; font-weight: bold;">new</span> PageList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #6666FF;">$pl</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">filterByCollectionTypeHandle</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'post'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #6666FF;">$pl</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">sortByPublicDateDescending</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #6666FF;">$posts</span> <span style="color: #339933;">=</span> <span style="color: #6666FF;">$pl</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #6666FF;">$nav</span> <span style="color: #339933;">=</span> Loader<span style="color: #339933;">::</span><span style="color: #00FF00;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'navigation'</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: #6666FF;">$posts</span> <span style="color: #b1b100;">as</span> <span style="color: #6666FF;">$p</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #999999; font-weight: bold;">?&gt;</span>
&nbsp;
         <span style="color: #339933;">&lt;</span>item<span style="color: #339933;">&gt;</span>
           <span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span><span style="color: #999999; font-weight: bold;">&lt;?=</span><a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$p</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">getCollectionName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #999999; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span>
           <span style="color: #339933;">&lt;</span>link<span style="color: #339933;">&gt;</span><span style="color: #999999; font-weight: bold;">&lt;?=</span>BASE_URL <span style="color: #339933;">.</span> <span style="color: #6666FF;">$nav</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">getLinkToCollection</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #999999; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>link<span style="color: #339933;">&gt;</span>
           <span style="color: #339933;">&lt;</span>description<span style="color: #339933;">&gt;</span>
           <span style="color: #339933;">&lt;!</span><span style="color: #009900;">&#91;</span>CDATA<span style="color: #009900;">&#91;</span>
            <span style="color: #999999; font-weight: bold;">&lt;?</span> <span style="color: #6666FF;">$a</span> <span style="color: #339933;">=</span> <span style="color: #999999; font-weight: bold;">new</span> Area<span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'Main'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #6666FF;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">display</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #999999; font-weight: bold;">?&gt;</span>
            <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;&lt;</span>br<span style="color: #339933;">/&gt;</span>
            <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #4444ff;">&quot;&lt;?=BASE_URL . <span style="color: #006699; font-weight: bold;">$nav-&gt;getLinkToCollection</span>(<span style="color: #006699; font-weight: bold;">$p</span>)?&gt;&quot;</span><span style="color: #339933;">&gt;</span>Comment on this at andrewembler<span style="color: #339933;">.</span>com<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
           <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span>
           <span style="color: #339933;">&lt;/</span>description<span style="color: #339933;">&gt;</span>
           <span style="color: #339933;">&lt;</span>pubDate<span style="color: #339933;">&gt;</span><span style="color: #999999; font-weight: bold;">&lt;?=</span><a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span> <span style="color: #4444ff;">'D, d M Y H:i:s T'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/strtotime"><span style="color: #990000;">strtotime</span></a><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$p</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">getCollectionDatePublic</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #999999; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>pubDate<span style="color: #339933;">&gt;</span>
         <span style="color: #339933;">&lt;/</span>item<span style="color: #339933;">&gt;</span>
      <span style="color: #999999; font-weight: bold;">&lt;?</span> <span style="color: #009900;">&#125;</span> <span style="color: #999999; font-weight: bold;">?&gt;</span>
&nbsp;
      <span style="color: #339933;">&lt;/</span>channel<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;/</span>rss<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #999999; font-weight: bold;">&lt;?</span>
&nbsp;
      <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div><p>As you can see, pretty straightforward. Call the PageList class, filter by post type, setup sorting, and print out RSS XML.</p><h2>/single_pages/feed.php</h2>
<p>This file is empty!</p>
<p>The controller contains the entire logic of the feed generator. The feed.php single page only exists so concrete5 will allow us to create it as a single page, through the dashboard. Simple and easy.</p>				<br/><br/>
				<a href="http://andrewembler.com/concrete5/building-a-custom-rss-feed/">Comment on this at andrewembler.com</a>
			  ]]>
			  </description>
			  <pubDate>Sat, 27 Feb 2010 09:00:00 EST</pubDate>
			</item>
		
			<item>
			  <title>The Apple iPad and The Era of Ubiquitous Computing</title>
			  <link>http://andrewembler.com/apple/the-apple-ipad-and-the-era-of-ubiquitous-computing/</link>
			  <description>
			  <![CDATA[
				<div class="tweetmeme_button" style="float: right; margin-left: 15px; margin-right: 5px;">
<iframe src="http://api.tweetmeme.com/button.js?url=http%3A%2F%2Fandrewembler.com%2Ffeed%2F&source=&style=normal&service=default" height="61" width="50" frameborder="0" scrolling="no">
</iframe>
</div><p>&nbsp;</p>
<p>On Wednesday, January 27, Apple introduced a project that's been in development for what can best be described as "fucking forever." The Apple Tablet &ndash; in whatever form that might take &ndash; has been a mainstay of Apple rumor sites since the death of the Newton in 1998. Interest in an Apple tablet has waxed and waned over the years, but just prior to this announcement, the hype bar had been set high, with reports about Apple speculation breaking out of the tech blogs and landing in mainstream newspapers, magazines, and television shows. Steve Jobs had even reportedly called the project the <a href="http://www.techcrunch.com/2010/01/24/steve-jobs-tablet-most-important/">most important thing he'd ever done</a>. Obviously Jobs has a remarkable gift for hyperbole, but he's never said anything like this about the Apple TV or the iPod. This product was going to be something special.&nbsp;</p>
<p>And, perhaps unfortunately for the iPad, it was amidst this aura of lofty expectations and frenzied interest that the actual device came. And the dismissals followed almost as quickly. Oh, not from me, of course. And not from <a href="http://www.ibtimes.com/articles/20100128/wall-street-calls-ipadgrand-slam.htm">the financial sector</a>. But from the tech press and those that read it? Disdain and derision. The reductive "fail!" could be found in the comments section of every article on the subject. Nevermind that these were the same people predicting the product would sell for twice its actual price. Nevermind that these people had never used the device in question. The backlash from many within the industry was swift and brutal.</p>
<p>And also wrong.</p>
<p>Much of the wailing in the tech press has been about what the iPad can't replace or augment. Each and every commenter and blogger seems to already have a home computer, a laptop and a smartphone, and finds it frustrating the iPad doesn't seem like a suitable addition to this lineup. But what about houses with only one computer, in which some additional web access, movie viewing or game play is desired? Our house was exactly such a place, a couple years ago, and I'll tell you this: every post-announcement morning, when I'm waking up with my cup of coffee and perusing my morning websites on the couch, I find myself staring with barely concealed hatred at the keyboard of the MacBook that I'm using. Oh, why can't you begone when I'm not using you!?</p>
<p>But even in my anecdote, I'm substituting a MacBook for an iPad. And I think that's part of the problem. In my example, and in all the examples posted by disgruntled Apple tablet devotees, we're thinking too small. I think the iPad is about to usher in an era of ubiquitous computing, in which computers are everywhere, fulfilling many functions, without the cruft of their lineage, like keyboards and mice. These things are thin and light enough that one might even mount them on a kitchen wall, or a refrigerator. Instead of a dashboard-mounted GPS device? Get an iPad. Instead of an in-car DVD player? Get an iPad. Instead of a bulky laptop to store recipes and podcasts on, for use in the kitchen? Get an iPad. These things are almost cheap enough to make that a reality. Like the iPod before it, these things are going to be everywhere. They're going to be appliances, with the power and backbone of a computer.</p>
<p>So, tech folks: don't ask how the iPad will replace a system in your highly ordered, highly scientific world view. We're tech people. We're kind the of people who organize our preference panes. We employ a meticulous file hierarchy. We keep our computer desktops free of virtual detritus.&nbsp;We owned MP3 players before iPods!&nbsp;We brainstorm features for email clients. Over drinks. In our LEISURE time! We enjoy using computers as much for the using of them, as we do to actually accomplish goals. The iPad can't compete with that. It wasn't built to. However, instead of lugging a laptop or netbook into the living room, kitchen, car, or on a plane, why not leave it in the den, and pick up an iPad instead. Hell, why not get two?</p>
<p class="byline">Andrew Embler would like two, please.</p>
<p>&nbsp;</p>				<br/><br/>
				<a href="http://andrewembler.com/apple/the-apple-ipad-and-the-era-of-ubiquitous-computing/">Comment on this at andrewembler.com</a>
			  ]]>
			  </description>
			  <pubDate>Mon, 01 Feb 2010 01:46:00 EST</pubDate>
			</item>
		
			<item>
			  <title>Creating a Simple concrete5 Wrapper Custom Block Template (Without Duplicating Code)</title>
			  <link>http://andrewembler.com/concrete5/creating-a-simple-concrete5-wrapper-custom-block-template/</link>
			  <description>
			  <![CDATA[
				<div class="tweetmeme_button" style="float: right; margin-left: 15px; margin-right: 5px;">
<iframe src="http://api.tweetmeme.com/button.js?url=http%3A%2F%2Fandrewembler.com%2Ffeed%2F&source=&style=normal&service=default" height="61" width="50" frameborder="0" scrolling="no">
</iframe>
</div><p>While wrapping up a site for a client, I encountered a problem that I decided to solve in new, more sensible way. You see, the client's concrete5 theme &ndash; as many do &ndash; has a sidebar with some special properties and CSS classes that differ a bit from the main content area. With this in mind, blocks of content and functionality, when added to the sidebar, need to be wrapped in some extra DIVs, to add additional style and padding to the content.</p>
<p>That's easy, right? That's concrete5 101: <a href="http://www.concrete5.org/help/building_with_concrete5/developers/understanding_blocks/customizing_a_blocks_appearance/" target="_blank">just create a custom template for your block</a>, and apply that to your block. Copy the view.php file from your core block into your local directory, and apply the changes there. Easy as pie! Right?&nbsp;</p>
<p>There's a problem with that approach. Read on for more.</p>
<h2>Custom Template Views: All or Nothing</h2>
<p>While the approach above is great and allows for endless flexibility, it's an all-or-nothing option: you have to copy <strong>all </strong>of the block's view template into your current directory, and work on the template that way. This is great when you want to make fundamental changes to the way the block appears, but when you just want to wrap the block in some content, and leave the block's actual view template unchanged, it's a bit cumbersome.</p>
<p>Furthermore, the two blocks I was working with were the form and the survey blocks. The view templates for these blocks are not lightweight. Plus, these blocks are complex. If the core view templates change in the future, I may miss out on some additional styles or features, having forked the entire template. It seemed like a bit much, since all I wanted to do was wrap the entire contents of the block in two DIVs.</p>
<h2>A Solution</h2>
<p>Fortunately, there's an easy solution to this problem.</p>
<ol>
<li>Create a custom template like you would at any other point.&nbsp;</li>
<li>Within this custom template, add the new DIVs required by the special custom template.&nbsp;</li>
<li>Within the DIV, instead of cutting and pasting the entirety of the block's view template, cut and paste this instead:</li>
</ol><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #999999; font-weight: bold;">&lt;?</span> </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666FF;">$bvt</span> <span style="color: #339933;">=</span> <span style="color: #999999; font-weight: bold;">new</span> BlockViewTemplate<span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666FF;">$bvt</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">setBlockCustomTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$bvt</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">getTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #999999; font-weight: bold;">?&gt;</span></div></li></ol></pre></div><p>I'll walk you through what's going on here. First, we instantiate the BlockViewTemplate class, with our current block's object passed into the constructor. This object is the $b object, and it is always in the scope of &nbsp;a block's view template.&nbsp;</p>
<p>Next, we call setCustomTemplate method for the block's view template, and pass false as its argument. Why? If we didn't do this, we'd have an infinite loop on our hands. That's because the block object we're currently working with already has a custom template. That's the template that we're rendering right now! So what we're doing here is basically refreshing the current block, and grabbing the template for the block when a custom template is not activated.&nbsp;</p>
<p>Finally, once complete, we call getTemplate() to return the block's template before a custom one was set. For the form, this will be /path/to/concrete/blocks/form/view.php. We include this, confident that it will continue to work and remain up to date in the future, and knowing we didn't have to duplicate a large amount of view code just to do something simple.&nbsp;</p>
<p class="byline">Andrew Embler just wants to make your coding life easier and a little more elegant.</p>				<br/><br/>
				<a href="http://andrewembler.com/concrete5/creating-a-simple-concrete5-wrapper-custom-block-template/">Comment on this at andrewembler.com</a>
			  ]]>
			  </description>
			  <pubDate>Wed, 20 Jan 2010 13:05:00 EST</pubDate>
			</item>
		
			<item>
			  <title>Optimizing your concrete5 Website for the iPhone</title>
			  <link>http://andrewembler.com/concrete5/optimizing-your-concrete5-website-for-the-iphone/</link>
			  <description>
			  <![CDATA[
				<div class="tweetmeme_button" style="float: right; margin-left: 15px; margin-right: 5px;">
<iframe src="http://api.tweetmeme.com/button.js?url=http%3A%2F%2Fandrewembler.com%2Ffeed%2F&source=&style=normal&service=default" height="61" width="50" frameborder="0" scrolling="no">
</iframe>
</div><h2>A mobile world.</h2>
<p>In the world of smartphones, the iPhone was a game-changer. We can debate the relative merits of the various players, but it can't be denied that, when it debuted, the iPhone brought a lot to the table. Nowhere is this more apparent than when using Mobile Safari. The world finally had a usable, standards-compliant mobile browser.</p>
<p>However, something interesting occurred almost immediatley after the iPhone was released. Web designers began creating iPhone-specific websites. These websites use stylesheets (and sometimes entire images and content) to tailor their form factor and presentation specifically to Mobile Safari. They will also frequently ape the iPhone aesthetic.&nbsp;</p>
<p>Initially, this puzzled me. If web designers are building standards-compliant websites with decent liquid layouts, Mobile Safari displays them quite well, and pretty quickly. For example, this site, when viewed on Mobile Safari, displays impressively well, with no tailoring toward Mobile Safari in particular.&nbsp;</p>
<p>However, as I started thinking about it, I realized that most websites aren't exactly like your garden variety blog. They have grown to include lots of JavaScript, images, and extraneous cruft that can slow down rendering on the iPhone's more lightweight processor. In these cases a mobile version can make a noticeable difference &ndash; even though the regular website could still easily be viewed.&nbsp;</p>
<h2>Enter c5touch.</h2>
<p>With all of this in mind, I present to you <strong>c5touch</strong>, a Mobile-Safari-optimized concrete5 theme.&nbsp;</p>
<div class="main-image">
	<div><img src="/files/9012/6362/3483/photo 2.jpg" class="footer-image" width="320" height="480" alt="footer image" /></div>


</div><p>c5touch is based on an impressive Wordpress theme named&nbsp;<a href="http://www.bravenewcode.com/wptouch/" target="_blank">WPTouch</a>. If you run a Wordpress blog, I highly recommend it. &nbsp;c5touch doesn't do half of what WPTouch does. This is partially because Wordpress, by its very nature, is a much more structured system than concrete5. But it's also because c5touch is young, and is being made available more as a simple exercise in what's possible in concrete5 with a little bit of tweaking. I would love for some enterprising soul to extend it in further directions. Consider this initial offering a proof of concept.</p>
<h2>Download, Installation and Setup Instructions</h2>
<p>concrete5 makes it easy to install and activate themes. c5touch is a little bit different, however, for one reason: it's not the only theme you're going to have on your site. c5touch compliments your site's main theme. You install c5touch, but you leave your site's main theme (or themes) activated, and add some code to your site to enable the usage of c5touch when concrete5 detects your site is being requested by Mobile Safari.</p>
<h3>Before You Start</h3>
<p><span style="color: #fcd63c; line-height: 22px;">1. Download c5touch</span></p>
<p><a title="c5touch.zip" href="/download_file/-/view/23/">Grab c5touch from here.</a></p>
<h3>2. Install c5touch on your site.</h3>
<p>FTP c5touch to the local themes directory on your site. Unzip it and install it through the dashboard. <strong>Don't activate it!</strong>&nbsp;(For more information on how to install a theme in your concrete5 site, <a href="http://www.concrete5.org/help/building_with_concrete5/developers/themes/" target="_blank">check out this link</a>)</p>
<h3>3. Modify concrete/libraries/view.php</h3>
<p>As of this writing, the latest stable release of concrete5 is 5.3.3.1. This tutorial requires a change to the core which have not yet been released. You can, however, add the change to the core file directly, confident that it will eventually be released.</p>
<p>First, locate the comment that says</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><span style="color: #999999; font-style: italic;">// Extract controller information from the view, and put it in the current context</span></pre></div><p>And add the following line above, so your source looks like:</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;">Events<span style="color: #339933;">::</span><span style="color: #00FF00;">fire</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'on_start'</span><span style="color: #339933;">,</span> <span style="color: #6666FF;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #999999; font-style: italic;">// Extract controller information from the view, and put it in the current context</span>
&nbsp;</pre></div><h3><br />4. Enable application events for your site.</h3>
<p>Enabling support for concrete5's application events allows site developers to hook custom application and website code into common concrete5 actions, without having to modify the core. These must be enabled first, however. Add the following line to config/site.php:</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'ENABLE_APPLICATION_EVENTS'</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></div></li></ol></pre></div><h3><br />5. Hook into the global "on_start" event.</h3>
<p>The on_start event (which we added to older concrete5 versions in step 3) is run by the view library at the very beginning of a page rendering session. This is before a theme or controller is loaded. It is here that we wish to check which browser is requesting our site and, if necessary, switch to our iPhone-optimized theme.</p>
<p>First, create a file named site_events.php in the config/ directory. Then, paste the following code into this file.</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;">Events<span style="color: #339933;">::</span><span style="color: #00FF00;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'on_start'</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'ThemeSwitcher'</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'checkForIphone'</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'libraries/theme_switcher.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div><p>This code may look complex, but it's fairly simple. The first argument, "on_start" is simply the name of the concrete5 application event we'd like to hook into (note, this is separate from controller-level or page-type-level events.) The second argument, "ThemeSwitcher" is the name of a class we're going to call a method in. The third argument, "checkForIphone" is the method in the ThemeSwitcher class that we're going to call. Finally, the fourth argument tells us where we can find the ThemeSwitcher class.</p>
<h3>6. Create the ThemeSwitcher class at the proper location.</h3>
<p>Now we need to create the proper class file at the location specified in step 5. Create an empty file in your local libraries directory, named "theme_switcher.php" Then, paste these contents into the file (minus the line numbers.)</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #999999; font-weight: bold;">&lt;?</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #999999; font-weight: bold;">class</span> ThemeSwitcher <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #999999; font-weight: bold;">public</span> <span style="color: #999999; font-weight: bold;">function</span> checkForIphone<span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$view</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/strstr"><span style="color: #990000;">strstr</span></a><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #4444ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'iPhone'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">         <a href="http://www.php.net/strstr"><span style="color: #990000;">strstr</span></a><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #4444ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'Android'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	 <a href="http://www.php.net/strstr"><span style="color: #990000;">strstr</span></a><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #4444ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'webOS'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">         <span style="color: #6666FF;">$iphone</span> <span style="color: #339933;">=</span> PageTheme<span style="color: #339933;">::</span><span style="color: #00FF00;">getByHandle</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'c5touch'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">         <span style="color: #6666FF;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">setTheme</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$iphone</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">      <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></pre></div><p>This is code is quite simple. It simply checks to the current request's user agent to see if it contains keywords that indicate the user is using a mobile webkit device. (Update: This now includes Android and Palm's webOS.) If so, we grab the theme object for the c5touch theme and render the view (which is passed as an argument to the method) using that theme.</p>
<h3>And that's it! Bask in the glow of iPhone compatibility.&nbsp;</h3><h2>Additional Notes and Other Helpful Tips</h2>
<p>Now, you'll probably notice that there is still a bit of work to be done to get your site to look top-notch on the iPhone. c5touch is a starter theme, but you'll still likely have to create page types and some custom style rules to really get everything to look great. Here are some things I've done on andrewembler.com to go the extra mile.</p>
<h3>1. Add some of your main site's css to the iPhone optimized theme by using c5touch/site.css.</h3>
<p>Your site may look somewhat drab. Copy some of the block-level and reusable styles that you're using throughout your site from your main theme, into the c5touch site, using the empty site.css stylesheet. For example, all my masthead images have drop shadows and some other effects applied to them. I copied this from my main theme into my iPhone-optimized theme.</p>
<h3>2. Scale images</h3>
<p>While my text looked great when I started using c5touch, the images within the content space were much too large, and looked silly. So I'm using the following custom code in my image block view template to scale them down.</p><div class="ccm-syntax-highlighter">
<pre class="html4strict" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #FFFFFF; font-weight: bold;">div</span></a> <span style="color: #6666FF;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main-image&quot;</span>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;?</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">$v <span style="color: #66cc66;">=</span> View::getInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">if <span style="color: #66cc66;">&#40;</span>$v-&gt;</span>getThemeHandle() == 'c5touch') { </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	$ih = Loader::helper('image');</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	$ih-&gt;outputThumbnail($f, 275, 1000);</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	?&gt;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;? <span style="color: #66cc66;">&#125;</span> else <span style="color: #66cc66;">&#123;</span> ?&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #FFFFFF; font-weight: bold;">div</span></a>&gt;&lt;<a href="http://december.com/html/4/element/img.html"><span style="color: #FFFFFF; font-weight: bold;">img</span></a> <span style="color: #6666FF;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?=$f-&gt;</span></span>getRelativePath()?&gt;&quot; class=&quot;footer-image&quot; </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">width=&quot;<span style="color: #009900;">&lt;?<span style="color: #66cc66;">=</span>$f-&gt;</span>getAttribute('width')?&gt;&quot; height=&quot;<span style="color: #009900;">&lt;?<span style="color: #66cc66;">=</span>$f-&gt;</span>getAttribute('height')?&gt;&quot; </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">alt=&quot;footer image&quot; /&gt;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #FFFFFF; font-weight: bold;">div</span></a>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;? <span style="color: #66cc66;">&#125;</span> ?&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;? if <span style="color: #66cc66;">&#40;</span>$altText<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> ?&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #FFFFFF; font-weight: bold;">div</span></a> <span style="color: #6666FF;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main-image-caption&quot;</span>&gt;&lt;?<span style="color: #66cc66;">=</span>$altText?&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #FFFFFF; font-weight: bold;">div</span></a>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;? <span style="color: #66cc66;">&#125;</span> ?&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #FFFFFF; font-weight: bold;">div</span></a>&gt;</span></div></li></ol></pre></div><p>This code ensures that, when images are displayed in the c5touch theme, they will be scaled down, using concrete5's autoresize algorithm (which takes care of caching, transparency, etc...)</p>
<h3>3. Experiment!</h3>
<p>This tutorial is meant as a starting point. Currently, c5touch is by no means a drop-in solution. If there's enough interest, I'll investigate expanding this into a concrete5 package. This would be ideal, as the package format could automate all of the various steps that currently have to be performed by a developer. But in the meantime, I'd love feedback from anyone, as well as suggestions. I hope this proves useful.&nbsp;</p>
<p class="byline">As CTO of concrete5, Andrew Embler is required to be tethered to his iPhone 24/7. This will make that a little bit easier. He would love to hear from you below, or through <a href="http://www.twitter.com/aembler">twitter</a>.</p>				<br/><br/>
				<a href="http://andrewembler.com/concrete5/optimizing-your-concrete5-website-for-the-iphone/">Comment on this at andrewembler.com</a>
			  ]]>
			  </description>
			  <pubDate>Sat, 16 Jan 2010 01:03:00 EST</pubDate>
			</item>
		
			<item>
			  <title>5 Easy Ways to Speed Up a concrete5 Site</title>
			  <link>http://andrewembler.com/concrete5/5-easy-ways-to-speed-up-a-concrete5-site/</link>
			  <description>
			  <![CDATA[
				<div class="tweetmeme_button" style="float: right; margin-left: 15px; margin-right: 5px;">
<iframe src="http://api.tweetmeme.com/button.js?url=http%3A%2F%2Fandrewembler.com%2Ffeed%2F&source=&style=normal&service=default" height="61" width="50" frameborder="0" scrolling="no">
</iframe>
</div><p>We've heard the criticism: concrete5 isn't as fast it should be, on low-end hardware. Know that we're taking this to heart with our next version, due out in several months. concrete5 version 4 should feature a number of improvements to speed up both the editing and viewing processes, including more AJAX-based editing (which reduces costly and time-consuming page refreshes) and much more usage of the built-in cache.</p>
<p>However, there are other ways to speed up a concrete5 site that can be done today. Your site can benefit by removing certain unneeded or unused portions of code.</p>
<h2>1. Don't use jQuery? Don't load it!</h2>
<p>concrete5 uses jQuery extensively, and we <strong>love</strong> it (at least, I do.) However, it's not necessary for all front-end functions. If you're not using jQuery in your site on every page, remove it from the required header for users who aren't logged in. This will ensure that the site doesn't load unnecesssary and costly JavaScript, while also keeping it editable.</p>
<p>To do this:&nbsp;</p>
<p>1. Copy concrete/elements/header_required.php into your local elements/ directory.<br />2. Open this file, and locate these lines:</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666FF;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">addHeaderItem</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">css</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'ccm.base.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'CORE'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666FF;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">addHeaderItem</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">javascript</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'jquery.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'CORE'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666FF;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">addHeaderItem</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">javascript</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'ccm.base.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'CORE'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li></ol></pre></div><p>3. Change those lines to this:</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$u</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">isRegistered</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #6666FF;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">addHeaderItem</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">css</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'ccm.base.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'CORE'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #6666FF;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">addHeaderItem</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">javascript</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'jquery.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'CORE'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #6666FF;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">addHeaderItem</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">javascript</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'ccm.base.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #4444ff;">'CORE'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></pre></div><h2>2. Don't make your theme editable.</h2>
<p>I think the way we've enabled designers to make editable stylesheets is one of concrete5's coolest, nearly-unknown features. (<a href="http://www.concrete5.org/help/building_with_concrete5/developers/themes/enabling_style_customization_in_your_theme/" target="_blank">Click here for an introduction and example</a>.) However, if you're working on a site for a client, you probably don't need this. Furthermore, did you know that by enabling this feature, you're parsing a stylesheet for editable rules, when you don't need to?</p>
<p>Granted, the stylesheet gets cached, and you're probably not losing a lot of performance. But every little bit helps, and waste is waste. To change this, look for any lines in your theme that are called this way:</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666FF;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">getStylesheet</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'my_stylesheet.css'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li></ol></pre></div><p>and change them to:</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #999999; font-weight: bold;">&lt;?=</span><span style="color: #6666FF;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">getThemePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #999999; font-weight: bold;">?&gt;</span><span style="color: #339933;">/</span>my_stylesheet<span style="color: #339933;">.</span>css</div></li></ol></pre></div><h2>3. Make sure you're running an opcode cache on your web server.</h2>
<p>This is a must. Make sure you're at least running Zend Optimizer on your web server. If at all possible, forego Zend Optimizer entirely, and use something like APC, XCache or eAccelerator. (Note: we used to recommend eAccelerator primarily, but its lack of maintenance concerns me. Perhaps APC instead?)</p><h2>4. Building Custom Blocks? Don't put expensive logic in their constructor!</h2>
<p>We've seen it frequently, and we may even have been guilty of it from time to time. What's that? Putting block startup logic in the block constructor (the __construct) method.</p>
<p>Why is this bad? Isn't that where it's supposed to go? Well, block's get instantiated at several points in concrete5, and that means that the block is going to run those functions every time that happens. Instead, stick your block startup logic in a method named "on_start." That method only runs once (plus, you can be sure it will run at the right point.)&nbsp;</p>
<h2>5. Use API Methods whenever possible.</h2>
<p>Rather than making custom calls to concrete5 tables, use the API methods if at all possible. How does this help performance? Well, here's the trick: it doesn't always. Sometimes (*gulp*) it might even hurt performance.&nbsp;</p>
<p>But - and this is a big but - in the long run, these are the best methods to use for performance and code accuracy. In version 4, we're going to be addressing caching for a large number of built-in objects, including attributes, users and files (pages and their attributes are already cached.) This means that if you use the built-in API for files or users, you'll automatically get caching, and that means performance increases.&nbsp;</p><p class="byline">Andrew Embler loves the thrill of watching a large number of SQL queries drop, drop, drop...</p>				<br/><br/>
				<a href="http://andrewembler.com/concrete5/5-easy-ways-to-speed-up-a-concrete5-site/">Comment on this at andrewembler.com</a>
			  ]]>
			  </description>
			  <pubDate>Tue, 12 Jan 2010 23:56:00 EST</pubDate>
			</item>
		
			<item>
			  <title>Welcome to My Website</title>
			  <link>http://andrewembler.com/web/welcome-to-my-website/</link>
			  <description>
			  <![CDATA[
				<h1><span style="color: #efefef; line-height: normal; font-size: 14px;">I'm migrating from electricstate.com to andrewembler.com. 2010: Out with the old, yadda yadda yadda... While this site will serve as a blog and project site, I hope it also showcases some interesting ways to extend <a href="http://www.concrete5.org">concrete5</a>.</span></h1>
<p>&nbsp;</p>				<br/><br/>
				<a href="http://andrewembler.com/web/welcome-to-my-website/">Comment on this at andrewembler.com</a>
			  ]]>
			  </description>
			  <pubDate>Wed, 30 Dec 2009 12:26:00 EST</pubDate>
			</item>
		
			<item>
			  <title>Arctic Blast</title>
			  <link>http://andrewembler.com/music/misc/arctic-blast/</link>
			  <description>
			  <![CDATA[
				﻿
			<h3>Arctic Blast</h3>
		
			<p>Recorded in Christmas 2008, as a response to the ridiculous hype over abnormal wintery weather conditions here in Portland, OR.</p>
		
	<script type="text/javascript">
		
		var flashvars = {};
		flashvars.audioPath = "/files/9212/5860/8843/Arctic Blast.mp3";
		flashvars.autoPlay = 0;
		flashvars.backgroundColor = "000000";
		flashvars.editMode = 0;
		
		var parameters = {};
		
				
		swfobject.embedSWF ("/packages/flash_audio/blocks/flash_audio/assets/AudioPlayer.swf", "flash_audio_201", "250", "25", "9.0.28", null, flashvars, parameters);
		
	</script>
	
	<div id="flash_audio_201"></div>
	<div style="font-size: 11px; padding-left: 5px">Download <a href="/files/9212/5860/8843/Arctic Blast.mp3">Arctic Blast.mp3</a></div>				<br/><br/>
				<a href="http://andrewembler.com/music/misc/arctic-blast/">Comment on this at andrewembler.com</a>
			  ]]>
			  </description>
			  <pubDate>Sun, 28 Dec 2008 12:00:00 EST</pubDate>
			</item>
		
			<item>
			  <title>Screencast: How to build a concrete5 Theme</title>
			  <link>http://andrewembler.com/concrete5/screencast-how-to-build-a-concrete5-theme/</link>
			  <description>
			  <![CDATA[
				
<div id="HTMLBlock161" class="HTMLBlock">
<object width="701" height="394"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=2982834&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=1CBBE5&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=2982834&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=1CBBE5&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="701" height="394"></embed></object></div><p>Additional concrete5 theme-related documentation can be <a href="http://www.concrete5.org/help/building_with_concrete5/developers/themes/">found at concrete5.org</a>.</p>
<h2>Code Recap</h2>
<p>
<p>The following are examples of the code that was used in the movie, to setup editable areas, and make a template editable.</p>
<h3>Add an area named "Main Content 2" to a page</h3>
</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #999999; font-weight: bold;">&lt;?php</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #6666FF;">$a</span> <span style="color: #339933;">=</span> <span style="color: #999999; font-weight: bold;">new</span> Area<span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'Main Content 2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #6666FF;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">display</span><span style="color: #009900;">&#40;</span><span style="color: #6666FF;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #999999; font-weight: bold;">?&gt;</span></div></li></ol></pre></div><p>
<h3>Make a template editable</h3>
<p>Remove the title tag from a template, and replace it with this:</p>
</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #999999; font-weight: bold;">&lt;?php</span> </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    Loader<span style="color: #339933;">::</span><span style="color: #00FF00;">element</span><span style="color: #009900;">&#40;</span><span style="color: #4444ff;">'header_required'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #999999; font-weight: bold;">?&gt;</span></div></li></ol></pre></div><p>
<h3>Common area and template names</h3>
<p><a href="http://www.concrete5.org/index.php?cID=2930">Standard area and template names for themes</a></p>
<p>Just to clarify, for those whose php is a little rusty and couldn't see the coding example in the video too well, the syntax for getThemePath is:</p>
</p><div class="ccm-syntax-highlighter">
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #999999; font-weight: bold;">&lt;?=</span><span style="color: #6666FF;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #00FF00;">getThemePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #999999; font-weight: bold;">?&gt;</span></div></li></ol></pre></div><p>
<p>And to insert it into a line that originally says:</p>
</p><div class="ccm-syntax-highlighter">
<pre class="html4strict" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">  <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/link.html"><span style="color: #FFFFFF; font-weight: bold;">link</span></a> <span style="color: #6666FF;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;style.css&quot;</span> <span style="color: #6666FF;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #6666FF;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></div></li></ol></pre></div><p>And add it like this:</p><div class="ccm-syntax-highlighter">
<pre class="html4strict" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/link.html"><span style="color: #FFFFFF; font-weight: bold;">link</span></a> <span style="color: #6666FF;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?=$this-&gt;</span></span>getThemePath()?&gt;/style.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;</div></li></ol></pre></div>				<br/><br/>
				<a href="http://andrewembler.com/concrete5/screencast-how-to-build-a-concrete5-theme/">Comment on this at andrewembler.com</a>
			  ]]>
			  </description>
			  <pubDate>Tue, 28 Oct 2008 10:41:00 EDT</pubDate>
			</item>
		
			<item>
			  <title>The Real Reason for the MacBook Air</title>
			  <link>http://andrewembler.com/apple/the-real-reason-for-the-macbook-air/</link>
			  <description>
			  <![CDATA[
				<p>
<h3>January, 2002</h3>
<p>Lackey: Hi, Steve? Er &ndash; sorry; Mr. Jobs? Hi, my name&rsquo;s Frank. I work down in, oh well, it&rsquo;s not important. Anyway, I just wanted to let you know that there&rsquo;s this site &ndash;&nbsp;Spymac &ndash;&nbsp;that&rsquo;s been getting a lot of press lately with some leaks about an Apple PDA. I know, I know &ndash;&nbsp;it&rsquo;s total bullshit. They&rsquo;re pulling these pictures out of their ass. But it&rsquo;s got people talking. Their mockups are really hideous, but what if we did something like that? Not something so played, like a PDA, but maybe something like PDA, phone combo? Wouldn&rsquo;t that be cool? Hello, hello?</p>
<h3>March, 2003.</h3>
<p>Lackey: Yes, Mr. Jobs? It&rsquo;s Frank again. Hey, I&rsquo;ve gotta tell you &ndash;&nbsp;we&rsquo;ve been monitoring Mac-related chatter in magazines and on forums, and there&rsquo;s this guy, Dvorak? You know him? God, he won&rsquo;t&nbsp;<strong>shut up</strong>&nbsp;about Apple switching to Intel processors. I know, I know! Please don&rsquo;t be angry with me &ndash;&nbsp;I know it&rsquo;s a pain in the ass, and would require massive developer support. Yes, I know it would be almost impossible to get legacy apps to run well. But, but we have to do<strong>something</strong>! He just won&rsquo;t shut up about it; he&rsquo;s driving everybody nuts!</p>
<h3>March, 2006</h3>
<p>Frank: Hey, Jobso! How&rsquo;s it going? I&rsquo;m bananas about Intel right now, B-T-W. Anyways, just wanted to let you know, there&rsquo;s a bunch of people running their mouth about that PDA rumor. I know, I know &ndash;&nbsp;I thought that we could shut&rsquo;em up with the Rokr too, but that thing was such a piece, right? Anyway, I still think it would kill, if we did it right.</p>
<h3>January, 2007.</h3>
<p>Frank: Stevie! What&rsquo;s happening? Congrats on the iPhone? That thing is pimp! It&rsquo;s gonna move like nothing else. Yeah, umm, that&rsquo;s what I&rsquo;m calling about. I know, I know &ndash;&nbsp;we&rsquo;ve given them Intel, we&rsquo;ve given them a goddamn phone &ndash;&nbsp;what more can these people want? Everything they ever crow about is getting handed to them and it&rsquo;s never enough. You know, I heard a few of them clamoring on, hoping that they&rsquo;d be able to make apps for the iPhone. I know! I told them that the web is gonna be really bangin&rsquo; on this machine, but they wouldn&rsquo;t let it go. We might need to look into that. Maybe some kind of SDK, some paltry gesture &ndash;&nbsp;well, we&rsquo;re gonna have to do something to shut these people up.</p>
<p>And that&rsquo;s not all. The latest thing? A subnotebook. Subnotebook. I don&rsquo;t even know what that means either! Doesn&rsquo;t matter that we make the best damn portables in the industry. They want something&nbsp;<strong>smaller</strong>! Something&nbsp;<strong>lighter</strong>! Yeah, it&rsquo;s horseshit, isn&rsquo;t it. Anyways, that&rsquo;s it.</p>
<h3>January, 2008</h3>
<p>Frank: Another killer keynote, Steve. Love the new iPhone firmware. Those dancing icons are the fucking best. Anyway, diggin&rsquo; the MacBook Air, the new Mac Pros. Seems like everything&rsquo;s sewn up, right? I mean&hellip;these rumor sites, they&rsquo;ve got everything now! I&rsquo;m predicting three months, max, and they&rsquo;ll be closing up shop. Talk to you later, buddy.</p>
<div></div>
<div class="social_bookmark">
<div class="inner"></div>
</div>
</p><p class="byline">Andrew Embler still thinks Apple humor is funny. He can followed and suitably congratulated on <a href="http://www.twitter.com/aembler">twitter</a>.</p>				<br/><br/>
				<a href="http://andrewembler.com/apple/the-real-reason-for-the-macbook-air/">Comment on this at andrewembler.com</a>
			  ]]>
			  </description>
			  <pubDate>Wed, 09 Jan 2008 13:10:00 EST</pubDate>
			</item>
				
		</channel>
	</rss>
	
	