#1 2013-02-05 01:04:05

Michel-Ange
Ionize Core Team
From: Paris, France
Registered: 2010-03-22
Posts: 927
Website

Events for Ionize !

We're currently developing Events for Ionize.

What brings Events ?
For those of you who knows the Observer pattern (http://en.wikipedia.org/wiki/Observer_pattern), nothing new, but the availability of Events observing and triggering for Ionize.

Events bring Ionize to a higher level. It is now possible, for modules, libraries, or controllers, to register methods which will "observe" events fired by the core.

For example, when one media id uploaded, one event is fired. This event will receive all the data of the uploaded media.

Let's imagine you have one module which has to know when one media is uploaded to the server and to do something after this event, this will be possible without hacking the core :
Just register one event listener method in your module, and that's it !

Which events are currently developed ?

...The most essential!

for the moment, the following events are done :

Article.save.before
Article.save.success
Article.save.error
Article.delete.success
Article.unlink.success

Page.save.before
Page.save.success
Page.save.error
Page.delete.success

Media.save.before
Media.save.success
Media.save.error
Media.link.success
Media.link.error
Media.link.external.success
Media.link.external.error
Media.unlink.success
Media.unlink.error

Filemanager.upload.success
Filemanager.upload.error
Filemanager.delete.success
Filemanager.rename.success

Category.save.success
Category.save.before
Category.save.error

When will this crazy feature be available ?

Very soon, that's why we're speaking about. Let's say for the 1.0, which will be released very soon !

Will other events be available ?

We will provide what we think to be the "must-have".
But if you think other events should be implemented, just tell us, and we will perhaps surely implement them !


Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

#2 2013-02-06 15:55:33

Kink
Ion Tester
From: France
Registered: 2010-06-04
Posts: 581

Re: Events for Ionize !

Ho yes, so cool.
Well, the first argument i see, is Article.save.success to update de sitemap.


Webmaster / OUF!WEB

Offline

#3 2013-02-09 13:53:17

aurex
Member
Registered: 2010-05-02
Posts: 49

Re: Events for Ionize !

Awesome, no more hack the core, just missing the delete event for Articles Pages and Medias smile

Offline

#4 2013-02-11 18:27:28

Michel-Ange
Ionize Core Team
From: Paris, France
Registered: 2010-03-22
Posts: 927
Website

Re: Events for Ionize !

@aurex : you're right, typo missing, they will be there !


Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

#5 2013-02-25 17:45:59

GWR
Member
Registered: 2013-02-25
Posts: 125

Re: Events for Ionize !

Concerning that event system: how does the system knows what modules are having X triggers and Y listeners?

I am asking because assume I have 20 modules installed. Some of them are having listeners for certain events, others provide events to listen for.
In the case of an event getting triggered: does the system check all modules ("hey module, do you have a listenerfunction named XYZ") or are you using a different approach?

In a multiclient cms I developed the last years I used a slight different approach concerning modules (which also improves "updateability"). Each module has a "install/update/uninstall"-function (they are based on a moduleBase). My system had a table holding information about modules (version, name etc.). If viewing the "modules"-section of my cms - more explizit: the admin view of the modules section - the system checked the modules-folder for all modules and lists all of them. This is nearly the same as Ionize does it at the moment, but as all modules are instantiated once in that case, the system is also able to know the modules version. If it is higher than the one from the database, the module->update($oldversion) function is called. Each module is then able to handle what to update and what not - just depending on the version string given.

This is not directly related to the topic but: Install/Remove/Update... are able to register listeners in a special table: moduleTriggers. So the system is able to query the database for modules using a certain trigger (onCreateArticle, ...).
Of course that system can be cached to a "trigger.php"-file which is loaded per "run". So you end up having a trigger.php file which has an array of available trigger->listeners. This also means one is able to skip the moduleListeners-table and ask all (active) modules for their triggers. But I am using the table-approach as I am having some more fields I use (concerning ACL).


So to sumarize: 
- make all modules able to listen/trigger functions
- make a list of all trigger->listener associations available
- use that list when your event system triggers an event (instead of just asking all available modules for their triggers -> ram consumption)

- not concerning events: store module version information and semiautomatic run update()-calls for them in the case of an update (check it in the module overview or the dashboard).


bye
Ron

Offline

#6 2013-02-26 13:35:46

Michel-Ange
Ionize Core Team
From: Paris, France
Registered: 2010-03-22
Posts: 927
Website

Re: Events for Ionize !

Ron,

About Events and modules
Each installed module has a dedicated Event class which register to the wished events. The core Event constructor is looking for this class. At startup, the "registration" method of each installed module is called and do the registration job.

Version of module
For the moment, as you noticed, no update system exists.
Of course we will think about for the next versions. I you wish to help to implement this, we're open.


Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

#7 2013-02-26 16:39:02

GWR
Member
Registered: 2013-02-25
Posts: 125

Re: Events for Ionize !

At startup, the "registration" method of each installed module is called and do the registration job.

This is what I wanted to avoid. Instead of crawling through the module directory looking for modules and then for their listeners, I think a "cached" result of that method should be available.

I know that memory consumption is not important for many smaller cms but with the increasing popularity of a site one should think about lowering overall usage. In case of an heavily used disk storage system the file traversals will be even slower.


@version:
Maybe I will do that later but at the moment my client does not seem to get "updates" in a later stage. If the company I am developing it for, will maintain the produced system later on, I surely will have to update the modules and therefor integrate an update system so they are able to integrate my updates without myself having the need of access to their servers.
Like said: the most work to do there is the traversal of installed modules on the modules-overview-page (send an ajax request to the first module ... after response, to the second which needs an update ...).
The "Module_Admin"-class just needs an public field holding an version string (no need to be numeric, later just check for installedVersion<>currentVersion) and a public function like "Update($versionString)".
Modules interested in updates then just have to overwrite that function and take care for it. Base "Update($versionString)" just does an Update of the version information in the database/cached-info-file. Modules then parent::Update... or you call an parental-function - this is a matter of prefered style.

Instead of that ajax-module-traversal one could also just (this is the way I have done it) mark an module with an "Update"-flag. So the admins have to click on the modules updatebutton to start an update. This way it is possible for a module to send back special html forms (eg. to setup new and required options - like google analytics id, account data for connectors...) - or you could print a "changelog" first ... multiple possibilities here.


bye
Ron

Offline

#8 2013-07-27 14:13:29

arif
Member
Registered: 2013-07-27
Posts: 1

Re: Events for Ionize !

hi there,

Are you guys planning to add an event Like :: Article.Before.Render.   or is it there ?

My Problem Scope:
1. If i put a certain tag in the articles like : [slideshow=1]
then before rendering the article in the front end a certain module can convert these tags into something i want.

I am a joomla and umbraco developer and both these frameworks provide these events so that a custom module can just convert these tags and render the desired html.

Thanks
Arif

Offline

#9 2013-08-31 10:40:11

Michel-Ange
Ionize Core Team
From: Paris, France
Registered: 2010-03-22
Posts: 927
Website

Re: Events for Ionize !

Good idea Arif.
We will add such kind of events.


Inspiration & Innovation : Websites by Partikule, Agence Web Paris

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations