$fileName = $modx->getTemplateVarOutput(array($key));
$fileName = $modx->getTemplateVarOutput($key )

i’ll test this out but I still need the output to have a wrapper.
Call me stubborn, but I can’t see why one single TV + one snippet wouldn’t achieve the same thing as 14 TVs + a snippet.
I don’t think that you have the correct syntax for $modx->getTemplateVarOutput
$fileName = $modx->getTemplateVarOutput(array($key));
// Loop Through the file array and output all the information
foreach ($file as $key => $value){
$fileName = $modx->getTemplateVarOutput(array($key));
$fileLoc = $modx->getTemplateVarOutput(array($value));
$outFileName = $fileName[$key];
$outFileLoc = $fileLoc[$value];
if (empty($outFileName) || empty($outFileLoc)) {
return '';
}
$outPutFile = "<li><a href=\"".$outFileLoc."\" title=\"Click to download ".$outFileName."\">".$outFileName."</a></li>\n";
$output = $outPutFile;
}
// Return $outPutFile
return $output;
}
if (empty($outFileName) || empty($outFileLoc)) {
return '';
}
if (empty($outFileName) || empty($outFileLoc)) {
break;
}
$outPutFile = "<li><a href=\"".$outFileLoc."\" title=\"Click to download ".$outFileName."\">".$outFileName."</a></li>\n"; $output = $outPutFile;
$outPutFile = "<li><a href=\"".$outFileLoc."\" title=\"Click to download ".$outFileName."\">".$outFileName."</a></li>\n"; $output .= $outPutFile;
<?php
/*
#
# RelatedInfo Snippet
# by Jay Gilmore (SmashingRed Web & Marketing)
#
*/
# Script Functions
function getFiles(){
# Assign a $modx as a global variable
global $modx;
$file["file1Text"]="file1";
$file["file2Text"]="file2";
$file["file3Text"]="file3";
$file["file4Text"]="file4";
$file["file5Text"]="file5";
$file["file6Text"]="file6";
$file["file7Text"]="file7";
$output ='<h6>Related Files</h6><ul>';
foreach ($file as $key => $value){
$fileName = $modx->getTemplateVarOutput(array($key));
$fileLoc = $modx->getTemplateVarOutput(array($value));
$outFileName = $fileName[$key];
$outFileLoc = $fileLoc[$value];
if (empty($outFileName) || empty($outFileLoc)) {
break;
}
$outPutFile = '<li><a href="' . $outFileLoc . '" title="Click to download ' .$outFileName. '">' .$outFileName. '</a></li>'."\n";
$output .= $outPutFile;
}
$output .='</ul>';
if (!empty($outPutFile)){
return $output;
}
else{
print '';
}
}
function getLinks(){
// Assign Variable to TV "relatedLinks"
$links = 'relatedLinks';
//Assign global scope to $modx
global $modx;
// Get Value of the RelatedLinks Template Variable
$relatedLink = $modx->getTemplateVarOutput(array($links));
$outLink = $relatedLink[$links];
if (empty($outLink)){
return '';
}
if (!empty($outLink)){
$output = '<h6>Related Links</h6>' . $outLink;
return $output;
}
else {
print '';
}
}
# Assign function output to variables
$getFiles = getFiles();
$getLinks = getLinks();
# Output the Output
if (!empty($getLinks) && !empty($getFiles)){
echo '<div class="sidepanel">';
echo "\n<h5>Related Info</h5>";
print $getLinks;
print $getFiles;
echo '</div>';
}
else{
echo '';
}
?>