Page 1 of 1

addCustomTag Question

Posted: Tue Mar 04, 2008 10:08 pm
by flyingeagle855
I am trying to do a little mod that needs to have some Java script in the <Head>. I read the wiki and it states to use the addCustomTag.

Code: Select all

global $mainframe;

$document =& JFactory::getDocument();
$document->addCustomTag('<script src="http://maps.google.com/maps?file=api&v=2&key=" type="text/javascript"></script>');
I tried placing this in the mod_name.php and helper.php and it's just not adding the line into the document head. Is this not pssible in a mod? or if I can how?

Thanks,
FlyingEagle

Re: addCustomTag Question

Posted: Thu Mar 06, 2008 7:44 am
by tekcronic
That is a good question.

You don't need:

Code: Select all

global $mainframe;
so remove it.

It makes sense that this would work with a module but then again I am not sure that it will because they are suppose to be small add-on pieces. I will check later to see if I can get it to work....

Re: addCustomTag Question

Posted: Mon Mar 24, 2008 7:01 am
by tekcronic
Sorry I still have not checked into this but i am sure you have though i just want to copy some code so that it may be found for any one who may looking for this kind of thing.

Code: Select all

defined( '_JEXEC' ) or die( 'Restricted access' );

JHTML::_('behavior.mootools');

//scripts
$document =& JFactory::getDocument();
$document->addCustomTag("<script src='components/com_helloworld/moolet/mootips.js' type='text/javascript'></script>");
$document->addCustomTag("<script src='components/com_helloworld/moolet/mootabs1.2.js' type='text/javascript'></script>");
$document->addCustomTag("<script type='text/javascript' charset='utf-8'>window.addEvent('domready', init);function init() {myTabs1 = new mootabs('myTabs', {height: '500px', width: '90%', useAjax: true, ajaxUrl: '/components/com_helloworld/moolet/controller.php', ajaxLoadingText: 'Loading...'});}</script>");

//CSS style sheets
$document->addHeadLink("components/com_helloworld/moolet/mootips.css", "stylesheet", "rel");
$document->addHeadLink("components/com_helloworld/moolet/mootabs1.2.css", "stylesheet", "rel");

//Made from helloworld MVC component
	echo JText::_('register');

Re: addCustomTag Question

Posted: Mon Mar 24, 2008 1:14 pm
by Rogue4ngel
I'm curious if your solution fixed flyingeagle's issue? Were you able to get it to work Tek?