0

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-

templates
|__mytemplate
|__|__index.php
|__|__component.php
|__|__myfile.php

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.

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

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

0

This template allows you to output as blank:

https://github.com/Lyquix/tpl_lyquix/blob/2.x/custom.dist.php

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:

//ECHO COMPONENT TYPE ()
$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.