Plugin - editing body and inserting scripts

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
dattard
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Apr 11, 2006 7:29 pm
Contact:

Plugin - editing body and inserting scripts

Post by dattard » Sat Nov 10, 2007 8:44 am

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.
http://www.dart-creations.com - We make Joomla Easy: Tutorials, Tips and Tricks, Featured Articles Module, Random Flash Module, Latest News Popup Module, MainMenu Images Module, Popin Window Module

http://www.joomlawire.com - The Joomla DIGG network - Submit and Vote for Joomla News!

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: Plugin - editing body and inserting scripts

Post by Opie » Sat Nov 10, 2007 1:00 pm

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.
http://springhillalumni.org • Springhill High School Alumni Association

User avatar
dattard
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Apr 11, 2006 7:29 pm
Contact:

Re: Plugin - editing body and inserting scripts

Post by dattard » Sun Nov 11, 2007 9:04 am

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?
http://www.dart-creations.com - We make Joomla Easy: Tutorials, Tips and Tricks, Featured Articles Module, Random Flash Module, Latest News Popup Module, MainMenu Images Module, Popin Window Module

http://www.joomlawire.com - The Joomla DIGG network - Submit and Vote for Joomla News!

User avatar
Pentacle
Joomla! Intern
Joomla! Intern
Posts: 61
Joined: Wed Oct 25, 2006 12:34 pm
Location: Turkey

Re: Plugin - editing body and inserting scripts

Post by Pentacle » Sun Nov 11, 2007 4:34 pm

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
My Joomla! 1.5 extensions - http://joomla.ercan.us
Progress is made by lazy men looking for easier ways to do things.

User avatar
dattard
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Apr 11, 2006 7:29 pm
Contact:

Re: Plugin - editing body and inserting scripts

Post by dattard » Wed Nov 14, 2007 8:43 pm

That's great. Thanks.

Anything similar available for 1.0.x ?
http://www.dart-creations.com - We make Joomla Easy: Tutorials, Tips and Tricks, Featured Articles Module, Random Flash Module, Latest News Popup Module, MainMenu Images Module, Popin Window Module

http://www.joomlawire.com - The Joomla DIGG network - Submit and Vote for Joomla News!


Post Reply