Sorry if this question may sound silly but I am searching and I can't find an answer nor any example. Let's say I have a library that contains various js files or css or even icons. I want to write various plugins that take advantage various components from that library. Obviously including that library with every plugin in its vendors folder is an overkill. The best way, I think, is to make a plugin that provides access to that library and the other plugins to consider the provider plugin a requirement and call components as they see fit.
For example let's say I have a library of icons. It has icons icon1.png, icon2.png and icon3.png. One way I am thinking is on the provide plugin initialization we have something like
$icon_library_path = '/mod/icon_library/vendors/icons';
export_path($icon_library_path); //<-How can I do this?
And then from the plugin that needs it
use_icon($icon_library_path);//<- and this
Or the same with javascript and css. I know about elgg_register_css but wouldn't it be better if the client plugin registers and calls the css as needed instead of having a bunch of css registered all the time even they are not needed?
I hope I described my problem accurately. Can you provide me some pointers on where to find such examples or maybe a plugin with similar functionality?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- Sisyphus@Sisyphus
Sisyphus - 0 likes
- Sisyphus@Sisyphus
Sisyphus - 0 likes
You must log in to post replies.For php libraries:
Then in the other plugins you can call:
Sounds like you already know how to do the js/css
It's insignificant overhead to register the libraries, so I would say register them in your library plugin then let other plugins do the loading as needed.
Thanks a lot for your answer. But how do I make a variable, declared in one plugin, available to other plugins? Something like a global variable. Like in the code I wrote in the first post. That of cοurse doesn't work but is there such possibility?
Another option I am thinking is to have in my mod directory a folder named eg: mod/vendors/my_icon_lib-1.0.2 and a soft link to that folder named mod/vendors/my_icon_lib and every plugin that needs stuff from that library considers given that there will be that folder mod/vendors/my_icon_lib which points to the correct version. And every time the lib is updated to a new version I just update the ln -s.
But I don't know if this is a correct way to do it or if this is a hack and there are better ways.
I found the elgg_set_plugin_setting() function. I think this is what I was looking.