We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    not 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.
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 28432
      • 372 Posts
      Quote from: Bruno17 at Apr 27, 2016, 11:07 AM
      not 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.

      Thanks Bruno for your suggest, but after looking to migxLoopCollection or pdoResources, I think i'm not good enough in developement (PHP POO) to do it !
      I will try because i don't like to fail but without conviction. I'm more like a WebMaster, like i always said, i know a bit of all but don't know all of one thing...
        • 28432
        • 372 Posts
        Quote from: Bruno17 at Apr 27, 2016, 11:07 AM
        not 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 !!!
          • 4172
          • 5,888 Posts
          great!

          you could do the same with:

          $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 */
          );
          
          $params['packageName'] = 'annonces';
          $params['classname'] = 'Annonces';
          $params['where'] = json_encode($where);
          $params['sortConfig'] = '[{"sortby":"DATE_OFFRE","sortdir":"DESC"}]';
          $params['tpl'] = $tpl;
          
          return $modx->runSnippet('migxLoopCollection', $params);
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 28432
            • 372 Posts
            Quote from: Bruno17 at May 02, 2016, 03:26 AM
            great!

            you could do the same with:...

            Thanks again Bruno ! I will try it smiley
            I did not understand what you mean in previous thread (feel like an idiot) !