Quote from: Bruno17 at Apr 27, 2016, 11:07 AMnot sure, if rowboat supports nested arrays as conditions, like xpdo and all snippets, which use xpdo does.
And you will need nested arrays in your case.
I would suggest to create a proper xpdo-package and use a snippet, which uses xpdo to generate the query, like migxLoopCollection or pdoResources.
Hi Bruno,
Like you suggest to me, I have made a xpdo package with migx ! I didn't think about it before...
1. Create new package-directory and an empty schema-file (with migx package manager)
2. Write schema from existing tables (with migx package manager)
3. Create xpdo-classes and maps if new or manipulate existing maps from schema (with migx package manager)
4. Create a couple of line (php code)
// For debugging:
$modx->log(modX::LOG_LEVEL_DEBUG
, '[test] called on page '. $modx->resource->id . ' with the following properties: '
.print_r($scriptProperties, true));
//Add in your package
$base_path = !empty($base_path) ? $base_path : $modx->getOption('core_path').'components/annonces/';
$modx->addPackage('annonces', $base_path.'model/');
// New Query
$c = $modx->newQuery('Annonces');
// Where Condition
$c->where(array(
'FK_TYPES_OFFRES:=' => '1', /* Equal To */
'TYPE_MANDAT:=' => 'EXCLUSIF', /* Equal To */
'VILLE_OFFRE:IN' => array('SIX FOURS LES PLAGES','LA SEYNE SUR MER'), /* IN statement */
));
// Sort By Condition
$c->sortby('DATE_OFFRE','DESC');
// Limit of result 0 = none
$c->limit(0);
// Call getCollection for result
$annonces = $modx->getCollection('Annonces', $c);
// Set tpl
$tpl = $modx->getOption('tpl',$scriptProperties,'listingBienTpl');
// Set value to placeholder getting chunk
foreach ($annonces as $annonce) {
$annonceArray = $annonce->toArray();
$output .= $modx->getChunk($tpl,$annonceArray);
}
// DEBUGGING
//$c->prepare();
//print $c->toSQL();
return $output;
Et voilà it work !
But maybe there another way with migxLoopCollection using runSnippet ?
return $modx->runSnippet('migxLoopCollection', $params);
Like usual many thanks Bruno !!!