Reputation: 13
I'm using a script module plugin that allow you to add scripts to a module in joomla, however I need this module to be inside the HEAD tag so I can place the scripts on the correct place.
Is there a way to create a custom module position inside of the head of the index page? so every time i create a module and assign that specific position something like "scriptTop" the script on that module will be placed inside the HEAD tag...
Does that makes sense?
cheers,dan
Upvotes: 1
Views: 1848
Reputation: 1814
As nibra said you can add a module name with in your index.php template and you are almost there
<head>
...
<jdoc:include type="head" />
<jdoc:include type="modules" name="scriptTop" />
...
</head>
but if you use an customHTML to add your metatags or code you will have the customHTML module default template with an unwanted div output.
To clean it out you can do a module template override in your own template coping the
modules/mod_custom/tmpl/default.php
into
yourttemplatename/html/mod_custom/newtemplatename.php
and just delete the unwanted divs:
<?php
// no direct access
defined('_JEXEC') or die;
?>
<?php echo $module->content;?>
then just select your new template from the modules option when you create a new one.
Upvotes: 1
Reputation: 4028
Yes, that is straight forward. Edit the file index.php
of your template, and change it this way:
<head>
...
<jdoc:include type="head" />
<jdoc:include type="modules" name="scriptTop" />
...
</head>
Then any module published in the scriptTop
position will be rendered in the head section. You must ensure that the code produced by the module is valid to be incorporated into the head section.
Upvotes: 0