我是 modx 的新手,对 PHP 的了解有限。我正在写一个片段并在语法上苦苦挣扎。我想输出模板变量列表框的占位符。我试图做的是获取电视列表框 ID 并遍历每个返回 html 的 ID。运气不太好。原谅我的愚蠢。
<?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;