Hello and welcome to my online works. Beyond my full-time job as a professional engineer, I have created and participated in several podcasts most notably Pragmatic.

I’ve also created a few projects and I also write longer-form articles from time to time. In addition I’ve been playing with comic strips recently with Enginerd.

Thanks for stopping by.

Conditional Blocks in Partials

12th June 2015


If you’re using a partial multiple times on a single page, keep the number of conditional code blocks within that partial to a minimum.


We all love partials. You know, those things where in your theme where you just call:

{{ theme:partial src="mypartialname" }}

But if you’re going to place them in a pages:listing or entries:listing and break out their functionality into smaller pieces that are lovely and modular that’s fine, until you end up with dozens of iterations of that partial on the page.

That’s the point though isn’t it? Well…yes. But the trap is to try and have a "god-partial" that is essentially an overloaded function that does layout for every flavour of that partial there is. Seems like it could be a good idea - you know - keep all of that object code in one place right? Well…no.

What am I jibbering on about? An example: (OPTION A)

{{ if { fileexists file=_myfile } }}<img src="{{ _myfile }}" alt="{{ name }}">
{{ else }}<img src="/assets/_myfile" alt="{{ name }}">
{{ endif }}
<div class="mytablelinks">
    {{ if _twitter|_facebook|_linkedin|_website }}<center>{{ endif }}
    {{ if _twitter }}<a href="{{ _twitter }}" title="{{ name }} on Twitter"><i style="font-size:38px;" class="fa fa-twitter-square"></i></a>{{ endif }}
    {{ if _facebook }}<a href="{{ _facebook }}" title="{{ name }} on Facebook"><i style="font-size:38px;" class="fa fa-facebook-square"></i></a>{{ endif }}
    {{ if _linkedin }}<a href="{{ _linkedin }}" title="{{ name }} on LinkedIn"><i style="font-size:38px;" class="fa fa-linkedin-square"></i></a>{{ endif }}
    {{ if _website }}<a href="{{ _website }}" title="{{ name }}'s Website"><i style="font-size:38px;" class="fa fa-globe"></i></a>{{ endif }}
    {{ if _twitter|_facebook|_linkedin|_website }}</center><hr class="mytable">{{ endif }}
    {{ content }}
{{ if false }}
    {{ mymeld:people person="{ name }" }}
        {{ if first }}
                <hr class="peopletable">{{ total_results }} episode{{ if total_results > 1 }}s{{ endif }}:<br>
        {{ endif }}
        <a href="{{ url }}">{{ segment_1|title }} {{ title }}</a>{{ if !last }}<br>{{ endif }}
        {{ if last }}
        {{ endif }}
    {{ /mymeld:people }}
{{ endif }}

Okay so that looks alright enough until we try to get clever like below (and I’m not repeating all that code again): (OPTION B)

{{ if condition="firstflavour" }}
    {{ if { fileexists file=_myfile } }}<img src="{{ _myfile }}" alt="{{ name }}">
    {{ else }}<img src="/assets/_myfile" alt="{{ name }}">
    {{ endif }}
    <div class="mytablelinks">
    {{ if false }}
        {{ mymeld:people person="{ name }" }}
        {{ /mymeld:people }}
    {{ endif }}
{{ endif }}

{{ if condition="secondflavour" }}
{{ endif }}

{{ if condition="thirdflavour" }}
{{ endif }}

The performance difference on a server will be better (you’d hope under moderate load conditions for page regeneration) but measured on my 2012 MacBook Air i7 2GHz running MAMP with a zippy SSD the improvement in rendering time from Option A to Option B was…

  • Option B: 28.7sec
  • Option A: 2.4sec

The ulimate solution was to split the flavours into three partial themes and the code is no longer in one place.

So instead of this…

{{ theme:partial src="mypartialname" condition="firstflavour" }}
{{ theme:partial src="mypartialname" condition="secondflavour" }}
{{ theme:partial src="mypartialname" condition="thirdflavour" }}

…it looks like this instead:

{{ theme:partial src="mypartialnamefirstflavour" }}
{{ theme:partial src="mypartialnamesecondflavour" }}
{{ theme:partial src="mypartialnamethirdflavour" }}

The lesson is, only call what you need to call in your partial and keep the logic as straight-forward as you can. Unless you want to write your own PHP Addon, which can save even more time depending on what you’re trying to accomplish.

Thanks To

The Statamic Debug Panel only introduced in v1.7.9 as it allowed me to track down the performance suckers in my website.

Statamic Tips & Tricks: An Introduction

12th June 2015

I’ve done an increasing amount of development in Statamic over the last 18 months to the point at which I’ve picked up a lot of things that aren’t in the documentation that might save present or future web-developers some time.

I’ve already had several posts along those lines:

This new site section is dedicated to the CMS I’ve come to enjoy using and am now working on several things that utilise it.

Hopefully these tips and tricks will help someone. If you’re a seasoned PHP developer or Statamic wizard, these tips are likely not for you. For everyone else, it’s all about caring and sharing. Or just sharing and crossing your fingers? Either works :)


9th May 2015

I’ve had my fair share of alcohol in my life. I’ve learned that I could drink most people under the table, though I never got the hang of beer or wine, only liqueurs and spirits. I’ve never had a hang-over. I like to think in my adult years I drank responsibly, mainly because I needed to drive a vehicle a lot. In Australia the drink driving limit is 0.05 grams of alcohol per 100mL of blood for those with an open drivers licence. (I referenced NSW but most states follow this AFAIK) and the guidelines that are often quoted for men are:

if no more than two standard drinks are consumed in the first hour and no more than one per hour after that…

…keeping in mind that a standard drink is any drink that contains 10g of alcohol; although the NSW Government site says of counting your drinks…

Trying to calculate your BAC is impossible…

Fast forward to about 12 months ago when I had Weight Loss Surgery I knew from my wife’s experience that the rate of absorption of alcohol is much faster and more intense as described here with the key point:

It is also harder to drink large amounts of alcohol after a sleeve and you will find that you will become twice as drunk, for twice as long on the same amount of alcohol! This is because the alcohol exits the stomach more rapidly and is very quickly absorbed.

I had been used to ‘pacing myself’ with alcohol intake such that I was able to drive if necessary and wasn’t impaired in my adult years. (Let’s exclude the teenage years from that though…)

That control is now impossible

The rules have changed far too much and try as I might, I can’t seem to get it right. It almost seems like any amount of alcohol has an adverse affect and I’m terrified to drive. There’s a school of thought that says if you’re going to drive you shouldn’t drink at all. Well I drive a car, every, single, day. So when is it okay/safe for me to drive a vehicle if I’ve had a drink if I can no longer trust the old guidelines?

And no, the answer isn’t to carry around my own personal breathalyser, I’m trying to figure out when a safe time is to actually drink and how much is safe ahead of swallowing?

What about the validity of 0.05 limit? Studies show that performance drops off sharply in areas of object recognition, reaction time and risk-judgement beyond 0.05 but this varies based on the individual. Safer still is 0.02 but then 0 is best. Of course a bad driver will always be a bad driver but a good driver plus any alcohol runs the risk of becoming a bad driver. The limit after which you are fined and disqualified from driving is legally fixed.

The problem I have is that I have four children and a wife that depend on me. At the moment even more so. So here we are. I think it’s time for me to say goodbye to alcohol.

It’s become something that is too difficult, dangerous and irresponsible to manage and should no longer play a part in my life. That said the most difficult part isn’t going to be giving it up, it’s going to be repeatedly explaining to others that no, I’m fine, I don’t want a drink thanks. What does that say about our society?