I am facing a problem to render a template after hitting a specific route.

Let me describe it a bit. I have a template structure like-


Now from a system plugin, I want to render just the myfile.php with its own scripts and styles when it hits the route index.php?option=com_ajax&mytemplate=1.

The myfile.php is a simple file.

    <jdoc:include type="head" />
<body class="contentpane">
    <jdoc:include type="component" />

Which I found to render a template file is like-

$doc->render(false, ['template' => 'mytemplate', 'file' => 'myfile.php']);

But the problem is, I don't get in which event is perfect for rendering the Document and I don't want any template specific styles/scripts. In other words, I just want to parse and render the myfile.php with its own styles/scripts.

Then which is the best event where I can attach the styles/scripts and render the myfile.php.

1 Answer 1


This template allows you to output as blank:


If you look at the tmpl_mode option for clues.

Also - this code could perhaps work in identifying the component (com_ajax) in your index.php:

$jinput = JFactory::getApplication()->input;

if(($jinput->get('option') == 'com_ajax')  && ($app->getTemplate('template')->id == 1)) {
  //load com_ajax CSS 
echo 'load com_ajax CSS';

 } else {

echo 'load normal CSS';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.