1

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?

Avatar
  • 14,622
  • 9
  • 119
  • 198

1 Answers1

0

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;
Miomir Dancevic
  • 6,726
  • 15
  • 74
  • 142