Hi, I’m new to snippit creation, and my php skills are weaker than the documentation of the modX API.
I’ve learned how to get the id of the current document’s template using
$modx -> documentObject[’template’]
but what I want is the current document’s template’s name. There is a templateObject, but there’s no documentation for it. I read that for revolution the name is called ’templatename’, though I’m not sure if this is true for 0.9.6, but whatever the case I’m stuck on how to return the template name to a variable.
Thank you so much for tolerating my current level of incompetence.
By the way, this is for a snippit I’m dveloping that will insert a chunk in a template if the current template is the named template, thusly:
[[ifSnippit? &template=`templatename` &trueChunk=`chunkName`]]
Revo 2.0.8-pl
Wow, geez, didn’t think it’s be so hard to access! Well, it’s not that hard, but I’d never have figured it out... thanks so much garryn!
Revo 2.0.8-pl
hallo,
I was looking for this (I want to set it as a class to the body, to have different CSS automatically linked to the template), but how do I use it? if I make a snippet [[GetTemplateName]] with the code:
<?php
$templateName = $modx->db->getValue('SELECT templatename FROM '.$modx->getFullTableName('site_templates').' WHERE id='.$modx->documentObject['template']);
?>
I don't get any result.
Where am I wrong?
THank you
MODx evo 1.5~1.6 ✪ Apache v 2.2.22 ✪ PHP v 5.3.10 ✪ MySQL v 5.1.61
<°'iiii);
maybe this:
<?php
$templateName = $modx->db->getValue( $modx->db->select( 'templatename', $modx->getFullTableName('site_templates'), 'id='.$modx->documentObject['template'] ));
return $templateName;
?>
:D yes, that's it.
Thank you so much!
MODx evo 1.5~1.6 ✪ Apache v 2.2.22 ✪ PHP v 5.3.10 ✪ MySQL v 5.1.61
<°'iiii);