If you are looking for how to include javascript in the head tag of html without having to write it in the template for features like sharethis, Google analytics here is how to
Simply use the following two lines:
$document = &JFactory::getDocument();
$document->addCustomTag('<script type="text/javascript">my javascript</script>');
And it will add javascript to the head tag.
You can also include js/css files by using
$document->addStyleSheet('path');
$document->addScript('path');
Simply use the following two lines:
$document = &JFactory::getDocument();
$document->addCustomTag('<script type="text/javascript">my javascript</script>');
And it will add javascript to the head tag.
You can also include js/css files by using
$document->addStyleSheet('path');
$document->addScript('path');
in what file to add the code you mentioned ?
ReplyDeletewhatever you are using in views/view_name/tmpl folder.. could be default.php or some other layout file.
Delete