Welcome Guest, Not a member yet? Register   Sign In
Allowing 3rd party modules to be added to a script
#1

[eluser]Jondolar[/eluser]
I want to have the ability for 3rd party "modules" to be added to a program I am releasing. I am looking for discussion resources as to the best approach for doing this. I have some basic ideas but don't know which would be best. In detail, I am looking for discussions/articles (or info added to this thread) on how to best approach allowing for 3rd party modules. Some of the questions I have are:

1. Is it best to require a record added to the database to inform the script that a new module has been implemented or should I just scan a directory for new files?
2. Is there a pattern for implementing this?
3. Is it normal to call a module once at the beginning of a function and then once again at the end of the function?
4. How best to expose the interface(s)?
5. Other considerations?

I know that the answers to these questions are all probably "it depends". I just need to find some discussions around this topic so I can come up with my own answer as to the best approach. Any resources or additional comments would be appreciated.

Thanks
#2

[eluser]Eric Barnes[/eluser]
Here is what I do:

1. All 3rd party code is activated and stored in a modules table. In admin the list is re-scanned with each page load and they are not put in the table until they are activated.
2. Not sure about a pattern.
3. I use modular extensions, an events system, and simpletags for the view.

So each 3rd party can have its own app or it can tie into the core with events.
Code:
$this->events->trigger('event/name', $data);

I also use a tags view system so 3rd party add-ons can tell the users what to add. Like:
Code:
{contact:form to="email"}
form fields go here
{/contact:form}
#3

[eluser]codeninja[/eluser]
[quote author="Eric Barnes" date="1283907495"]
Code:
{contact:form to="email"}
form fields go here
{/contact:form}
[/quote]

Hey Eric,

How are you parsing the tags in {} brackets? Any specific library that you are using?
#4

[eluser]Eric Barnes[/eluser]
Yea I am using Dan's simple tags - http://hg.dhorrigan.com/simpletags/src

Awesome system.
#5

[eluser]codeninja[/eluser]
Cool that is a great library, but I don't know how it can be used for multiple triggers.. ie.

{contact:form}
something here
{/contact:form}

{page:title}

etc..
#6

[eluser]Eric Barnes[/eluser]
Yea it is actually very powerful with the callback system. If you want to see it in use check out the latest pyrocms. It is now moving totally to the tags system.




Theme © iAndrew 2016 - Forum software by © MyBB