romanum Reply #1, 4 months ago
Hi,
I am hoping someone could help me out with a snippet I have written? Basically the snippet is working great (thanks to Shaun http://rtfm.modx.com/display/revolution20/Templating+Your+Snippets and Bob http://bobsguides.com/custom-db-tables.html). It returns all the info I need from a custom table and allows you to add a template and rowClass as parameters.
The question I have is how to alternate the rowClass? I would need to add another parameter to the snippet call like
My Snippet Code:
I know this is probably more of a php question but any help or advice would be great!
Many Thanks
I am hoping someone could help me out with a snippet I have written? Basically the snippet is working great (thanks to Shaun http://rtfm.modx.com/display/revolution20/Templating+Your+Snippets and Bob http://bobsguides.com/custom-db-tables.html). It returns all the info I need from a custom table and allows you to add a template and rowClass as parameters.
The question I have is how to alternate the rowClass? I would need to add another parameter to the snippet call like
&altClass=`someClass`
My Snippet Code:
<?php
// 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
$rows = $modx->getCollection('ITS',array('isbn'=>$isbn));
$tpl = $modx->getOption('rowTpl',$scriptProperties,'itsRowTpl');
$rowClass = $modx->getOption('rowClass',$scriptProperties,'brown');
$output .= '<p>Total: '. count($rows) . '</p>';
foreach($rows as $row) {
$resourceArray = $row->toArray();
$resourceArray['rowClass'] = $rowClass;
$output .= $modx->getChunk($tpl,$resourceArray);
}
return $output;I know this is probably more of a php question but any help or advice would be great!
Many Thanks