I am developing a plugin for adding YUI bits to EE. Most YUI functions require some dependancy javascript to be loaded, then some javascript specific to that function and then a bit of javascript code is run. This is the way I want to implement it.
The template might look like this:
.. my page header stuff
{yui_dependancies} <---- this has all the javascript files required for tabs and tables and no duplicates
more of my template
{exp:yui:load type="tabs"} <---- javascript for tabs loaded here
more of my template.....
[exp:yui:load type="tables"} <---- javascript for tables loaded here
As the plugin function load is called, the dependancies files are added to the global variable yui_dependancies so when global variables are parsed at the end of the template, the {yui_dependancies} should be replaced by the list of javascript files to load.
However, I can’t work out how to put stuff into $IN->global_vars[‘yui_dependancies’]. I have set the initial value in path.php and it is that original value that is displayed in the template.
Now there might be a whole better way of doing this and I am very open to ideas!
Phoebe,
Not sure I quite understand the question.
It seems you have a few different possible YUI functions that you want to allow users to load later in a template using this kind of syntax:
{exp:yui:load type="tabs"}
These functions have differing dependencies and you want to load only those dependencies that are actually needed for a given mix of functions.
Am I reading you correctly?
Jamie
OK,
Here is my suggestion. Rather that try to keep track dynamically have parameter on the {dependencies} tag where you enter in all of the functions being used.
Doing it dynamically is going to be very difficult via a plugin because plugins are parsed as they occur in a template.
So if {dependencies} is above the items depending on it it will get parsed before them and thus not know what they are and what they are doing.
So you end up with something like this instead:
{yui_dependancies loaded="tabs|tables"}
more of my template
{exp:yui:load type="tabs"}
more of my template.....
[exp:yui:load type="tables"}
Jamie
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.