Hello
I have the following TVs:
gallery_1_img, gallery_1_txt, gallery_2_img, gallery_2_txt, etc... (1 through 10)
I need to do a loop through all those TVs and check if they have been filled out. If a TV has been filled out I need to output the value. I’m thinking i need to create a snippet, but that’s about as much as I can figure out myself. Can anyone point me in the right direction.
Any help is greatly appreciated
Jonas
You could have a look at the getTemplateVars API function, I’ve never used it but it seems to return the contents of template variables associated with the template the current document is using, or if specified another one. The problem you might have is ’to check if they have been filled out’. Not sure how you’d do this safely, there is no ’content is valid’ flag or some such to test here.
There’s also getTemplateVar and getTemplateVarOutput as well.
Use MODx, or the cat gets it!
you can get this:
http://modxcms.com/Docmanager-881.html
and try it with something like that: (not tested)
<?php
$path='./assets/snippets/path_of_documentclass/';
require_once($path.'document.class.inc.php');
$docid=$modx->getDocumentIdentifier;
$doc = new Document($docid);
for ($i = 1; $i <= 10; $i++) {
$tv='tvgallery_'.$i.'_img';
$imgtv=$doc->Get($tv);
$tv='tvgallery_'.$i.'_txt';
$txttv=$doc->Get($tv);
$output.=$i.':'.$imgtv.':'.$txttv.'<br/>';
}
return $output;
?>