AnswerBun.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!

Related Questions

Generating a module instance from PHP

0  Asked on September 5, 2021 by ffrewin

   

Embed custom JS app in Joomla MVC

0  Asked on September 5, 2021 by miasto

     

Error when updating Gantry from 4.1.20 to 4.1.32

1  Asked on September 5, 2021 by norberto-gomes

       

Change user permissions programmatically on the fly

1  Asked on September 5, 2021 by aheavyobject

   

Akeeba backup update broke the site

2  Asked on September 5, 2021 by hamlet-kraskian

   

Proper way for autoloading in Joomla 4

1  Asked on September 5, 2021 by webchun

     

Menu Specifically For Super Users

1  Asked on September 5, 2021

       

Joomla PHP does not match host PHP

2  Asked on February 18, 2021

     

Controller Joomla – Output Class construct for color css style

1  Asked on February 5, 2021 by andrea-suriani

       

Joomla custom component – router not find alias

1  Asked on January 21, 2021 by lecraver

     

Joomla 3 call model function inside controller

3  Asked on December 28, 2020 by wbdevlop

   

Product url problem after updating VirtueMart

1  Asked on December 23, 2020 by kiasaty

     

Display intro image inside mod_breadcrumbs

0  Asked on November 11, 2020 by geoplous

   

Ask a Question

Get help from others!

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