addCustomTag Question

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
flyingeagle855
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu May 11, 2006 8:14 pm
Location: California USA
Contact:

addCustomTag Question

Post by flyingeagle855 » Tue Mar 04, 2008 10:08 pm

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

tekcronic
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Wed Nov 15, 2006 12:17 am
Location: USA - Ohio

Re: addCustomTag Question

Post by tekcronic » Thu Mar 06, 2008 7:44 am

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....

tekcronic
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Wed Nov 15, 2006 12:17 am
Location: USA - Ohio

Re: addCustomTag Question

Post by tekcronic » Mon Mar 24, 2008 7:01 am

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');

User avatar
Rogue4ngel
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 199
Joined: Sun Nov 26, 2006 10:46 pm
Location: New York

Re: addCustomTag Question

Post by Rogue4ngel » Mon Mar 24, 2008 1:14 pm

I'm curious if your solution fixed flyingeagle's issue? Were you able to get it to work Tek?
If you're not a part of the solution, you're a part of the problem.


Post Reply