EE Extensions, Erik Reagan

EE Extensions, Erik Reagan Picture

One of the least understood aspects of ExpressionEngine is the class of add-ons known as Extensions. Many developers don’t understand why they exist, what they actually do or what problems they solve. This confusion exists among both Extension users and developers alike. A quick browse of any ExpressionEngine support forum shows that a common first step to solving an issue is to “Disable all Extensions,” yet most don’t know why. This session is designed to demystify the world of Extensions. The goal is to help everyone, from the general user to the new add-on developer, understand why Extensions exist, what they do and how they work.

@erikreagan http://focuslabllc.com/blog

The Anatomy of an Extension, Demystify the world of extensions. What they do, how they work.

Extensions in the context of add-ons.

Plugins

  • Runtime add-ons
  • No settings interface
  • No installation required
  • No unique DB tables
  • No language file
  • Can format custom text fields
  • Can provide template tags
  • Small learning curve

Accessories

  • Only shown in control panel
  • EE handles installation and settings
  • Small learning curves
  • CP interface of some sort
  • Requires lang file
  • Must be installed in CP
  • Can utilize actions
  • Can provide template tags

Fieldtypes

  • Fairly self-explanatory
  • Have template tags

Extensions

  • Have to be installed in CP
  • Can use EE's built in simple settings builder
  • Requires lang. file
  • Can have unique DB tables (but often don't)
  • Manipulate data or processing during a given point in a page load
  • Must behave nicely with other extensions
  • Probably the steepest learning curve in add-ons
  • Can only be used with system hooks

What are hooks?

Hooks are

  • Not unique to EE
  • used to alter or augment the behavior of an OS or application without having to hack or change the core files.
  • Primary benefit is to allow developers to extend a product.

With great power comes great responsibility.

How do hooks relate to extensions?

EXP Extensions Table

Hook processing

  • EE encounters a hook in the system
  • It checks the exp_extensions table to see if there is record with the hook where the enabled column is set to Y or N
  • If there is an extensions then EE looks at the class column to see which it needs to load
  • If the add-on Extension file exists, it is loaded.
  • Within that Extension class, the method listed is loaded.
  • Extension Table
  • Class - Name
  • Method - Method or function to be executed
  • Hook Column - Do we have an extension with a hook that we encountered?

Hook belongs to EE, Method belongs to the Extensions

Extension Processing

Currently (v2.5) there are 100 hooks to make EE do something that it could not have done or do it in a different way.

Caveats

  • Any extension being called by EE can tell EE that it wants to be the last thing run.
  • Extensions need to play well with others!

Debugging Methods

  • Disable all extensions in the CP
  • Disable all extensions in the config.php file
  • Disable one extension at a time in the database
Disable Extensions - Does not delete settings, data, etc., whereas if you disable specific extensions, you risk losing extension data, settings, etc.

Page that's not working as expected.

  • Look through the code to find the hooks that are used.
  • Disable extension with the offending hooks using PHPMyAdmin or a visual DB editor.

Highly recommend using version control on projects. Allows you to hack core and still have the ability revert.

Slides

  • http://focuslabllc.com/blog/the-anatomy-of-an-expressionengine-extension

⇠ Next Article Previous Article ⇢

About The Author

G. Brad Hopkins's avatar
  • G. Brad Hopkins
  • About Me: I bought my first computer - an Apple Performa 6320 - when I was in college and have been building websites ever since. These days I spend most of my time writing code and helping to bring interesting projects to life.
  • @gbradhopkins