Post Image
By Matt GaidicaApril 17, 2012In Uncategorized

Creating a Simple Expression Engine Plugin

Expression Engine is usually great, but I think we all wish there was either more support for advanced PHP functions, or PHP wasn’t such a mess to work with within templates files. I also find plugins for simple things discouraging- after a while you end up with a long list of miscellaneous plugins which is a maintenance disaster waiting to happen.

My solution to getting around all of these issues in Expression Engine is to simply toss in a plugin, and add what I need to it. In Expression Engine 2, plugins live in “system/expressionengine/third_party” and require a folder name that matches the plugin name.

Github Gist

I just named my plugin the name of my company, so it is easy to distinguish, so I first created a folder “prime” with the “third_party” folder. Next, I added a file name “” to the “prime” folder. The plugin itself is a PHP class exposed to Expression Engine by a tag pair, formatted as “{exp:class:function}tagdata{/exp:class:function}”.

View the Github Gist for

Once the file is created, it is accessible in your templates and you can starting making magic.

{exp:prime:no_spaces}Holy crap this is easy!{/exp:prime:no_spaces}
result → Holycrapthisiseasy!

result → (650) 963-6889

{exp:prime:strip allow="<span>"}<p>This section is <strong>super</strong> awesome and <span>amazingly simple</span></p>{/exp:prime:strip} 
result → This section is super awesome and <span>amazingly simple</span>
svgConditional Tag Pair Content in Expression Engine
svgSinatra and Domain Specific Languages