Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HTML 5 Joomla head override - Переписываем вывод HEAD для Joomla 2.5 в соответствии со стандартами HTML5
<?php
// no direct access
defined('_JEXEC') or die;
// Variables
$doc = JFactory::getDocument();
$user = JFactory::getUser();
$template = 'templates/' . $this->template;
// get html head data
$head = $doc->getHeadData();
// remove deprecated meta-data (html5)
unset($head['metaTags']['http-equiv']);
unset($head['metaTags']['standard']['title']);
unset($head['metaTags']['standard']['rights']);
unset($head['metaTags']['standard']['language']);
// Robots if you wish
//unset($head['metaTags']['standard']['robots']);
if($user->guest){
// Mootools remove for unregistered
unset($head['scripts'][$this->baseurl . '/media/system/js/mootools-core.js']);
unset($head['scripts'][$this->baseurl . '/media/system/js/mootools-more.js']);
unset($head['scripts'][$this->baseurl . '/media/system/js/core.js']);
unset($head['scripts'][$this->baseurl . '/media/system/js/caption.js']);
unset($head['scripts'][$this->baseurl . '/media/system/js/modal.js']);
}
$doc->setHeadData($head);
// New meta
$doc->setMetadata('X-UA-Compatible', 'IE=edge,chrome=1');
$doc->setMetadata('viewport', 'width=device-width, initial-scale=1.0');
// Copyrights
$doc->setMetadata('Author', 'Серега Мочалов');
$doc->setMetadata('copyright', htmlspecialchars($app->getCfg('sitename')));
//Yandex and Google Webmaster-tools if you wish
//$doc->setMetadata('yandex-verification', 'xxxxxxxxxxxxxxxx');
//$doc->setMetadata('google-verification', 'xxxxxxxxxxxxxxxx');
//Remove or rewrite ($doc->setGenerator('your generator');)
$doc->setGenerator('');
//Add your styles
$doc->addStyleSheet($this->baseurl. '/templates/system/css/system.css');
$doc->addStyleSheet($this->baseurl. '/templates/system/css/general.css');
$doc->addStyleSheet($template.'/css/joomla.css');
$doc->addStyleSheet($template.'/css/template.css');
$doc->addStyleSheet($template.'/css/theme1.css');
?>
<!DOCTYPE HTML>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<meta charset="utf-8" />
<jdoc:include type="head" />
</head>
@thejohn

This comment has been minimized.

Copy link

thejohn commented Nov 13, 2014

Nice solution, thanks.

@webmasterMeyers

This comment has been minimized.

Copy link

webmasterMeyers commented Aug 17, 2015

in Joomla 3.x.x just use

$doc = JFactory::getDocument();
$doc->setHtml5(true);

This will add <meta charset="utf-8" /> and remove <meta http-equiv="content-type" content="text/html; charset=utf-8">

@sobchenyuk

This comment has been minimized.

Copy link

sobchenyuk commented Sep 6, 2017

unset($this->_metaTags); joomla 3.7 == unset($head['metaTags']['http-equiv']);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.