MODX Evolution. It is possible to get Template Variable ID in template?

865 views Asked by At

I need to know which ID the Template Variable (TV) has, to put it into a form in the template.

Something like this:

<input type="text" value="[template_variable_id]" />

Does MODX Evo have some special tag for it, which can be used in templates?

1

There are 1 answers

0
Miomir Dancevic On BEST ANSWER

That’s because $modx->resource is always the currently loaded document. If you’re calling a snippet, you need to pass in the current ID:

[[!mySnippet? &resourceId=`[[*id]]`]]

Snippet mySnippet

  $resource = $modx->getObject('modResource',$resourceId);
    $template = $resource->get('template');
    echo $template;