// add package so xpdo can be used:
$path = MODX_CORE_PATH . 'components/its/';
$result = $modx->addPackage('its',$path . 'model/','modx_');
//$isbn = parameter value passed from snippet call
//$outerTpl = parameter value passed from snippet call
//$rowTpl = parameter value passed from snippet call
//$rowClass = parameter value passed from snippet call
//$altClass = parameter value passed from snippet call
$rows = $modx->getCollection('ITS',array('isbn'=>$isbn));
$outerTpl = $modx->getOption('tpl',$scriptProperties,'itsTpl');
$rowTpl = $modx->getOption('rowTpl',$scriptProperties,'itsRowTpl');
$rowClass = $modx->getOption('rowClass',$scriptProperties,'white');
$altClass = $modx->getOption('altClass',$scriptProperties,'brown');
$i = 0; //Starts row count at 0
$output = $modx->getChunk($outerTpl,$resourceArray);
foreach($rows as $row) {
if($i % 2 == 0){
$itsClass = $rowClass;
}else{
$itsClass = $altClass;
}
$resourceArray = $row->toArray();
$resourceArray['itsClass'] = $itsClass;
$rowOutput .= $modx->getChunk($rowTpl,$resourceArray);
$i++;
}
return $output;This question has been answered by Wanze. See the first response.
$i = 0; //Starts row count at 0
foreach($rows as $row) {
if($i % 2 == 0){
$itsClass = $rowClass;
}else{
$itsClass = $altClass;
}
$resourceArray = $row->toArray();
$resourceArray['itsClass'] = $itsClass;
$rowOutput .= $modx->getChunk($rowTpl,$resourceArray);
$i++;
}
$rowsPlaceholder = array('rows' => $rowOutput);
$output = $modx->getChunk($outerTpl,$rowsPlaceholder);
return $output;
[[+rows]]