Which Joomla Platform / CMS class should I extend in order to make my own custom JDOC:include tags?
I would like to have custom JDOC tags like
<JDOC:include type="scripts" />
<JDOC:include type="scripts-body" />
and a bunch of other types.
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.
Sign up to join this communityWhich Joomla Platform / CMS class should I extend in order to make my own custom JDOC:include tags?
I would like to have custom JDOC tags like
<JDOC:include type="scripts" />
<JDOC:include type="scripts-body" />
and a bunch of other types.
The solution for this question is as follows:
One needs to add a new file at the location below, to add a custom jdoc tag..
libraries/joomla/document/html/renderer/
File name should be same as the tag you are adding.. suppose one wants to use scripts as tag then file name should be scripts.php
Now in this file one needs to add a code like below. As tag name is scripts so class name should be JDocumentRendererScripts
<?php
defined('JPATH_PLATFORM') or die;
class JDocumentRendererScripts extends JDocumentRenderer
{
public function render($scripts, $params = array(), $content = null)
{
$contents = "";
//Do your work here
return $contents;
}
}
?>
Now one can use custom jdoc code
jdoc:include
comes from the _parseTemplate()
function, from the JDocumentHTML
class, from the following file:
libraries\joomla\document\html\html.php