Last Updated: February 25, 2016
·
502
· teknonono

Modify head in Joomla page

//First get the current document object
$doc = &JFactory::getDocument();

//Will create a empty generator meta tag. If you dont want 
//everyone to know site is running on Joomla.
$doc->setGenerator();
//Sets the description meta tag
$doc->setDescription('some desc');
//sets the title tag
$doc->setTitle('Some Title');
//create a meta tag
$doc->setMetaData($name,$content);
//adds a linked style sheet
$doc->addStyleSheet('/path/to/file')
//adds a linked javascript or other type of script file
$doc->addScript('/path/to/file')
//add a custom tag. Use to add any kind of tag to the head section.
$doc->addCustomTag();
//Add custom javascript code snippet. Pass in javascript code and 
//will add the <script> tags for you. Joomla places these snippets 
//after placement of addScript() scripts.
$doc->addScriptDeclaration()
//Add custom css style snippet. Pass in css styles and will add 
//the <style> tags for you. Joomla will place these styles after 
//placement of addStyleSheet() styles.
$doc->addStyleDeclaration()