Recent Topics

1 Feb 28, 2010 20:29    

I need to insert some js into the generated page from a plugin, either added to the onload event or as a one time thing.

I have a js file loaded, in SkinBeginHtmlHead function, by the plugin that needs jquery to be loaded before it will run. The problem if I load jquery in SkinBeginHtmlHead it will possibly conflict with the already embedded version. I can extract the required code, but how do I get it to run when the page is loaded?

Any idea?

2 Feb 28, 2010 21:35

I did find in _plugins_admin.class.php a list of supported hooks including SkinEndHtmlBody. I tried that and it works. Putting the code at the end of the body is fine, but it would be nice to have SkinStartHtmlBody and SkinEndHtmlHead. Also an SkinAddToBodyTag hook could be useful. I maybe over-thinking this as jquery can handle this programmagically.

Also have to remember with skins and plugins to reload them before testing.

Any comments?

3 Mar 01, 2010 13:40

If your code works with the shipped version of jquery then you can do :

functionSkinBeginHtmlHead()
{
  require_js('#jquery#');
  require_js( $this->get_plugin_url().'your.js', true);
}

¥

4 Mar 01, 2010 19:23

That's pretty much what I need. Is there another php function require_css?

Most important is to follow the 'standard' so that my work, if good enough, will be accepted and shared with others.

5 Mar 01, 2010 19:25

There is, and you'll never guess at it's name :p

require_css( file, [boolean] absolute path );

false == /rsc/css/file

¥

6 Mar 01, 2010 20:01

:p, I figured it out for myself.

	require_css($this->get_plugin_url()."css/jquery-1.3.2-lightbox-1.0.css", true);


Thought it might be useful for someone else on the same path though.

Does lead to another question. What is the function of the true/false absolute path?

7 Mar 01, 2010 20:16

false == "load from /rsc/[css||js]/[path/file]" (depending on the require_*() hook)

true == "load from url given"

There's also "add_headline()" which will spit out the results in <head />

¥


Form is loading...