XF 2.1 How to distinguish if we are rendering a frontend template or a template for the dashboard?

Cylon

Member
Dear friends,

I'm injecting some js files using a code event listener. Concretely, I'm using the templater_setup event, and the callback for this event receives following parameters:

\XF\Container $container, \XF\Template\Templater &$templater

What I'm doing inside my event listener is the following:


PHP:
if ( $container->getOriginal( "app.classType" ) === "Admin" ) { //Skip if we are rendering a template in the dashboard, because the files are not needed

   return;

}
$templater->includeJs( [ 'src' => 'myjavascript.js, 'min' => true ] );

This does not work very well. Maybe you know another way to distinguish if we are rendering the frontend / dashboard to inject some custom scripts.

Thanks!
http://localhost:8080/admin.php?code-events/listeners/templater_template_post_render.34/delete
 

Cylon

Member
I have no idea how that url ended there. Is the url of my development environment, sorry, but it has nothing to do with the question.

To many open windows!!! ;)
 
Top