Make a Lasting Impression
ImpressCMS Blog > Going Deeper: Preloads

Going Deeper: Preloads

learn more about ImpressCMSSince we are now focusing on publishing patches for very specific features, there are lots of opportunities to go deeper under the covers of ImpressCMS and expand, strengthen and share what makes it so great. Patches aren't just quick fixes, they have a lot of value in so many ways. 

We need to bring attention to why someone would want to use ImpressCMS instead of another sytem, like Wordpress, Joomla!, Drupal or XOOPS. There is so much we have available to us, just waiting to be discovered!

Take the recent patch for Smarty and the email protection feature as an example - it wasn't really a fix, just an update to an external library and a small improvement that makes future updates easier. And, it also separated some code we had added into Smarty that didn't need to be there. To accomplish this, we leveraged the preloads feature - custom actions you that can be triggered by events throughout the core.

Other platforms use different language to describe this feature - they are commonly called hooks, listeners, or events. ImpressCMS uses these triggers for some of our best features - custom tags, multilanguage, autotasks, and now - email protection.

I've already blogged about separating the email protection from Smarty, so I won't go into that much more. But, it does offer us a perfect opportunity to examine this powerful feature in the core, improve some of our documentation - in the code comments, the wiki and also provide a video to accompany them all.

So, after all that, here's what has come out of a single, simple patch - 

  • An update to an external library (Smarty)
  • A separation of email protection from the template engine (the template engine really has nothing to do with this)
  • Updated code documentation for preloads
  • Updated wiki information about preload events
  • A video explaining the basics of preloads

All posts by skenow
Subscribe to latest posts
The comments are owned by the poster. We aren't responsible for their content.
Poster Thread
Madfish
Posted: 2013/11/17 11:29  Updated: 2013/11/17 11:29
Home away from home
Joined: 2007/12/4
From:
Posts: 1199
 Re: Going Deeper: Preloads
Video looks great thanks, but I lose sound just before the 5 min mark?
skenow
Posted: 2013/11/17 14:54  Updated: 2013/11/17 14:54
Home away from home
Joined: 2007/12/4
From:
Posts: 4237
 Re: Going Deeper: Preloads
hmm, I may need to dub that in - I'm not sure why the sound cuts out.
fiammybe
Posted: 2013/11/17 21:33  Updated: 2013/11/17 21:33
Home away from home
Joined: 2009/3/3
From: Belgium
Posts: 1944
 Re: Going Deeper: Preloads
Added this video to ImpressCMS.tv here
skenow
Posted: 2013/11/19 0:26  Updated: 2013/11/19 0:26
Home away from home
Joined: 2007/12/4
From:
Posts: 4237
 Re: Going Deeper: Preloads
I've re-mastered the audio and uploaded to YouTube again. Unfortunately, YouTube doesn't allow you to replace existing videos and dubbing in the audio wasn't so simple with their editor. So, the links in the blog post are updated to point to the new video and the old links are still valid, but the video won't be visible on my stream.
Madfish
Posted: 2013/11/20 1:06  Updated: 2013/11/20 1:06
Home away from home
Joined: 2007/12/4
From:
Posts: 1199
 Re: Going Deeper: Preloads
Thanks, I appreciate the videos, makes the code a lot more accessible to me.
skenow
Posted: 2013/11/21 2:20  Updated: 2013/11/21 2:20
Home away from home
Joined: 2007/12/4
From:
Posts: 4237
 Re: Going Deeper: Preloads
You're welcome - that's the whole idea behind them and the patches!
lotus
Posted: 2013/12/4 20:33  Updated: 2013/12/4 20:33
Home away from home
Joined: 2009/11/16
From: Germany
Posts: 173
 Re: Going Deeper: Preloads
Thanks for the video Steve!

Would be great(er) if you start your video with an frontend-example like:
how does it look like without a preload and what's happend with preloads....
just to make clear what this is good for.

Not all users are able to understand the code, but they like to know what's this about.
skenow
Posted: 2013/12/7 21:25  Updated: 2013/12/7 21:25
Home away from home
Joined: 2007/12/4
From:
Posts: 4237
 Re: Going Deeper: Preloads
Good idea, Chris. The videos have focused more on the developer/builder experience and are connected to the patches being published. In the future, there will be more administrator/user topics to include.
QM-B
Posted: 2013/12/24 14:49  Updated: 2013/12/24 14:49
Home away from home
Joined: 2010/2/12
From: Germany
Posts: 679
 Re: Going Deeper: Preloads
Nice Post But in the documentation I am missing two useful Events from System Module: savingSystemAdminPreferencesItem and afterSaveSystemAdminPreferencesItems, which are triggered before saving preferences and after saving.

Also a suggestion for additional Events: for deleting users it would be nice, if an Event can be triggered, since this might be useful to be used in modules. The same for registering/activating an user.
skenow
Posted: 2013/12/24 22:13  Updated: 2013/12/24 22:13
Home away from home
Joined: 2007/12/4
From:
Posts: 4237
 Re: Going Deeper: Preloads
It's always a work in progress

I've added more events to the list in the wiki, based on the additions in the code documentation.

Preloads are only 1 way for defining and triggering events. icms_Event adds a completely new dimension for listening and responding to events in the core and even in other modules. Once the event is defined, you can attach to those events and your code will also be triggered by that event, without having to add a preload.
fiammybe
Posted: 2016/11/16 22:11  Updated: 2016/11/16 22:11
Home away from home
Joined: 2009/3/3
From: Belgium
Posts: 1944
 Re: Going Deeper: Preloads
3 years later and still working on this... but we're getting there



Would you be able to write a blogpost or a forum item on how to work with the icms_Event class. Perhaps after that even a comparison when to use what? I'm trying out different kind of techniques for the new ImpressCMS site and this is an area with huge potential, but zero doc