I am new to modx and have limited knowledge of PHP. I'm writing a snippet and struggling with the syntax. I want to output placeholders of template variable list-box. What I have tried to do is to get the TV list-box IDs and loop through each one returning the html. Not having much luck. Forgive my stupidity.
<?php
$o='';
$docid=$modx->resource->get('id');
$show = $modx->resource->getTVValue('showHideContacts');
$heading = $modx->resource->getTVValue('contactTitle');
$staffVar=$modx->getObject('modTemplateVar',26);
$staff = $staffVar->getValue($docid);
if($show =='value1')
{
//opening
$o.='<div class="row">
<div class="span9">
<div class="footerContact">
<h3><i class="icon-mail-circled"></i>'. $heading .'</h3>
<div class="row">';
if (!empty($staff)) {
foreach($staff as $staff) {
$name = $staff->resource->get('pagetitle');
$title = $staff->resource->get('longtitle');
$number = $staff->resource->get('description');
$email = $staff->resource->get('introtext');
$o .= '<div class="span3">
<ul class="contactDetails">
<li><b>'. $name .'</b></li>
<li>'. $title .'</li>
<li>'. $number .'</li>
<li><a href="mailto:'. $email .'">'. $email .'</a></li>
</ul>
</div>';
}
}
//close
$o.='
</div>
</div>
</div>
</div>';
}
return $o;
I got the result I wanted. Resorted to PHP and SQL instead of modx syntax.