Hey all,
I'm trying to get an embedded gallery2 page working in b2evolution much the same way that the wordpress plugin works. It works for the most part but I am having trouble with where to place the javascript and css files that are included as part of the gallery2 theme.
Right now I have to do something like this to generate an embedded gallery2 page.
$gallery = $this->runGallery($baseurl, $embeduri);
This gives me an array with keys 'bodyHtml', 'javascript', 'css' which each contain html.
I would like to put the css and javascript in the head portion of the page but I don't want the overhead of running gallery (reading the gallery database generating a gallery2 page etc) on every b2evo page. I would like to be able to tell if I'm viewing the gallery2 embedded page from within the SkinBeginHtmlHead plugin hook.
Right now I have a very cobbled and broken implementation tries to figure out if you are viewing it based on the current url in SkinBeginHtmlHead. runGallery is called there and the bodyHtml is saved in a member variable for later use by DisplayItemAsHtml. This currently breaks with different url schemes.
Is there a good way to do this? I can put the css and javascript html in the post body but that just seems wrong. I could also put them in the footer via SkinBeginHtmlFooter since that is called after any calls to DisplayItemAsHtml. I could probably do that safely for javascript but it would be dumb to do that for css.
I'm open to other possibilities such as putting the javascript and css elsewhere or creating some kinds of options for setting the javascript and css manually via a plugin option but those would largely depend on what theme you had selected in gallery2 (I'll investigate possibilities such as forcing the use of particular themes when generating gallery2 pages also).
Any help or advise would be appreciated.
I'm assuming by the fact that you're using DisplayItemAsHtml() that there's something in the post body that triggers a gallery ?
In which case :
¥