Building a plugin framework

Hello all. I'm slightly new to Elgg, so please bear with me, especially if this is a stupid question.

I have already created 2 plugin prototypes using the blog tutorial. I plan to create a plugin framework that will interface with (i.e use data from) these two plugins, perform some computations and eventually end up giving the user a recommendation.

What I would like to know is:

1. Is this even possible in the first place? If not, is there any other way to achieve this functionality?

2. Is there a similar framework already in existence? 

  • 1. Sure is possible

    2. Not really, as any such integration is so customized depending on the data types that are being worked with

    Also, it depends on what you mean by framework.  Many people have created 'framework' plugins that contain 'convenience' functions that they reuse in dependent plugins, which ultimately ends up being an abstraction of the Elgg API.  While this sounds logical at first, it becomes a maintainability nightmare when bugs in the framework ripple through multiple plugins, or changes in Elgg create a ripple effect.

    The right way to do this without running into a maintainability issue is by using the Elgg API in your plugins, and using that to have them interact.  You can trigger custom events, or plugin hooks at will, and have other plugins perform tasks or modify data using those pathways.

    That's the easiest and most maintainable way to proceed.  There may be a bit more of a learning curve than writing your own thing, but it's well worth it in the long run.

  • Hmmm alright. Thanks for the prompt reply. Looks like i have a bit of reading to do.

    If its not too much trouble, could you give me a quick example of how a plugin would read data created by another plugin? Off the top of my head, it seems like i would need to find the guid of the object created, and then get further details based on that guid. Or is there a simpler way?



    For the scenario you propose the event is already defined and triggered in Elgg any time any entity is created, so if one plugin creates something another plugin can jump in on that event and do it's own thing.


    elgg_register_event_handler('create', 'object', 'myplugin_object_create');

    function myplugin_object_create($event, $type, $object) {
        // do stuff with $object

  • Oooooh thats very helpful! I'll post back here in case I come across more doubts.

    Thank you!