Page 1 of 1

Plugin - editing body and inserting scripts

Posted: Sat Nov 10, 2007 8:44 am
by dattard
Hi,

I have a client who (despite my protests on intrusive advertising) wants to create a popin on his site. I can do this quite easily if I had to do it manually, however instead of just doing it I would like to create a plugin which does this does and then put the extension in the JED (as I've already done before when I had ideas which I think can be re-used).

My question is, to create the plugin, I need to insert scripts in the head and in the body, and edit the body tag such I nsert onload scripts. Can this be done via a plugin? If yes, can someone provide a small example of how to do this?

I've got a background in web application development, but not much background in php / joomla development, so I'm familiar with the concepts but not with the APIs / methodology of doing this.

Re: Plugin - editing body and inserting scripts

Posted: Sat Nov 10, 2007 1:00 pm
by Opie
I'm not much of a php / joomla developer, yet.

Will these scripts be the same on all pages?  If they will be the same, can you put this into the template?

Or are they database driven?  I wouldn't know how to do this at the moment.

Re: Plugin - editing body and inserting scripts

Posted: Sun Nov 11, 2007 9:04 am
by dattard
Yes I can put them in the template, but it is something I would like to avoid. If I can do it in a plugin, I had just call {popin} on a page particular content item, and they only get rendered in that particular page.

Any other suggestions please?

Re: Plugin - editing body and inserting scripts

Posted: Sun Nov 11, 2007 4:34 pm
by Pentacle
You can use JHTML::script() for files or $document->addScriptDeclaration() for including a variable that contains JS code in head. I think these two links will be useful for you:
http://api.joomla.org/Joomla-Framework/ ... tml#script
http://api.joomla.org/Joomla-Framework/ ... eclaration

Re: Plugin - editing body and inserting scripts

Posted: Wed Nov 14, 2007 8:43 pm
by dattard
That's great. Thanks.

Anything similar available for 1.0.x ?