Hi to all !
The $mainframe->addCustomHeadTag function works fine.
It just adds its html argument to an array property of the $mainframe object (which acts as a buffer).
It works so well that you can even use it within modules, your html will be added to the $mainframe property... but will never be included within the section of your template ! In fact, once the mosShowHead() function is fired in the section of your template, using the $mainframe->addCustomHeadTag function afterward (in a module, for instance) is simply useless.
I've founded a solution to this problem which consists in restructuring the code inside the index.php file of any standard joomla templates so that the mosShowHead() function is fired AFTER the LAST call of the $mainframe->addCustomHeadTag function.
Let's start with a standard joomla template index.php file :
Code:
<!-- JOOMLA HEADERS -->
<head>
<?php mosShowHead(); ?>
<!-- OTHER STUFF -->
</head>
<body>
<!-- BODY PART -->
</body>
</html>
This file should be restructured as follows :
Code:
<!-- JOOMLA HEADERS -->
<?php
//Start output buffering
ob_start();
?>
<!-- BODY PART -->
<?php
//Store the contents of the buffer in the $body variable
$body = ob_get_contents();
//Stop output buffering
ob_end_clean();
?>
<head>
<?php mosShowHead(); ?>
<!-- OTHER STUFF -->
</head>
<body>
<?php echo $body; ?>
</body>
</html>
Using this approach will help you to easily create effective XHTML-valid modules.
PS : Sorry for the last reply

-BoR