pepebe
12/18/2014 - 9:24 AM

Insert name of current template into a template/chunk/etc.

Insert name of current template into a template/chunk/etc.

/*
TemplateName snippet
--------------------
author: @BobRay
source: http://forums.modx.com/thread/95171/how-do-i-put-a-class-name-in-the-body-of-my-posts#dis-post-515486

example usage: <body class="[[TemplateName]]" >
*/

$query = $modx->newQuery('modTemplate', array(
    'id' => $modx->resource->get('template'),
));
$query->select('templatename');
return $modx->getValue($query->prepare());