TransWikia.com

Render a template after a specific route by using system plugin

Joomla Asked by Sajeeb Ahamed on February 7, 2021

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.

One Answer

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';
  
}

Answered by iamrobert on February 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP