i'm creating a website in PHP, that has Javascript elements as well. This one, will be having what is like a plugin system where a plugin can be dynamically added to the website.
I've created the plugin system, but i don't like certain elements of the design. In particular, i'm using an MVC pattern, but there is a problem with javascript abstraction.
I have a certain file that loads all the plugins. Then, there is a javascript file that dynamically adds boxes to a window, depending on the selection that was made, for what plugin should be used.
It goes like this in a js file :
if (SelValue == 'image_list')
image_list(form_name, new_div, parent_div);
if (SelValue == 'multiple_columns')
multiple_columns(form_name, new_div, parent_div);
Then, right below, follows the declaration of imagelist() and so on. Of course, this is pretty cumbersome and certainly does not look like a good practice. I would like to have all of these abstracted and isolated, so that a plugin is just a simple step to add to my code, if possible.
Do you know of any design pattern or practice that could fit this scenario ?