3

I am trying to get more control over the header of my Joomla site; for some pages I don't need many things in the header. I decided to make a template where I don't use the <jdoc:include type="head" />, because it loads lot of things that I don't need.

Searching, I found this old post about the subject, and in the web some people looking for the same thing. Manually control <head> markup in Joomla

I was wondering if it is possible to add to my index.php template file to PHP code that could get just the "metadescription" and the "title" of the Joomla publication. Something like this:

  <?php defined( '_JEXEC' ) or die; ?>
    <!doctype html>
    <html lang="<?php echo $this->language; ?>"> 
    <head> 
    <meta name="viewport" content="width=device-width />
    <meta name="description" content="<?php echo **code metadescription** ?>" />
    <title><?php echo **code to get title** ?></title>
    </head>
    <body> 
    <jdoc:include type="component" />  
    </body>
    </html> 
hat
  • 781
  • 2
  • 14
  • 25
Diogo Wernik
  • 586
  • 8
  • 24

3 Answers3

7

Nice, after while i could find the code that i was looking for, and maybe it could help others, it worked for me... in the index.php file of the template i added:

<?php defined( '_JEXEC' ) or die;
$doc =JFactory::getDocument(); 
$meta_description = $doc->getMetaData("description"); 
$title = $doc->getTitle();
?>
<!doctype html>
<html lang="<?php echo $this->language; ?>">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> 
<meta name="description" content="<?php echo "$meta_description"; ?>" />
<title><?php echo "$title" ?></title> 
</head>
<body> <jdoc:include type="component" />  </body>
</html> 
Flimm
  • 136,138
  • 45
  • 251
  • 267
Diogo Wernik
  • 586
  • 8
  • 24
0

Just use PHP include() function

In top.php

<meta name="viewport" content="width=device-width />
<meta name="description" content="<?php echo **code meta description** ?>" />
<title><?php echo **code to get title** ?></title>

And in your current file just include the file(top.php) like

<?php defined( '_JEXEC' ) or die; ?>
    <!doctype html>
    <html lang="<?php echo $this->language; ?>"> 
    <head> 
    <?php include("top.php"); ?>
    </head>
    <body> 
    <jdoc:include type="component" />  
    </body>
    </html> 
Bruce
  • 1,647
  • 4
  • 20
  • 22
  • hi, thanks for the tip, i am a php beginner , would be possible to help me with " **code for joomla core meta description** and **code for joomla core title** " ... i could not find that yet :) , if i find i will post here – Diogo Wernik Jun 16 '15 at 11:58
0

I don't know if this is a good way, but you can unset all css and js in the following style:

unset($doc->_styleSheets[$this->baseurl.'/path/to/some.css']);
unset($doc->_scripts[$this->baseurl.'/path/to/some.js']);

I recommend not to remove meta tage like content-type or x-ua-compatible. These tags support your website in some browsers. And the favicon link is helpful by bookmarks.

Alex
  • 927
  • 1
  • 12
  • 18