We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33392
    • 8 Posts
    well the the snippet no pass the data to the page.


    this is the snippet code, the xpdo work .

    
    <?php
    include $modx->config['base_path'] . '/core/components/trex/model/trex/trexciudadaviso.class.php';
    $dsn = 'mysql:host=localhost;dbname=modelos;port=3306;charset=utf-8';
            $xpdo = new xPDO($dsn,'root','');
            ///verifica coneccion.
           // echo $o=($xpdo->connect()) ? 'Connected' : 'Not Connected';
            $xpdo->addPackage('trex','/Modx3/core/components/trex/model','');
    
    $query = $xpdo->query("select NombreAviso,Ciudad,Imagen,Url from listamodelos");
    
    
    ///this work 
    foreach ($query as $row)
     {
      echo $row['NombreAviso'] . ", " . $row['Ciudad']. ", " . $row['Imagen']. ", " . $row['Url'] . "<br>\n";
    }
    
    
    ///this no work 
    
    foreach ($query as $resource)
     {
    $output = $modx->getChunk('tplfront',$resource->Array(
    'Urls'=>$row['Url'] 
    ,'Ciudads'=>$row['Ciudad']
    ,'Imagens'=>$row['Imagen']
    ,'NombreAvisos' =>$row['NombreAviso']));
    
    }
    return '<ul class="columns">'.$output.'</ul>';
    


    this is the chunk
    <li>
    <a href="[[+Urls]]"><img src="[[+Imagens]]" alt="[[+NombreAvisos]]" /></a>
          <div class="info">
            <h2>[[+NombreAvisos]]</h2>
            <p>[[+Ciudads]]</p>
          </div>
          </li>
    

    well any help is welcome.
    solution

    <?php
    include $modx->config['base_path'] . '/core/components/trex/model/trex/trexciudadaviso.class.php';
    $dsn = 'mysql:host=localhost;dbname=modelos;port=3306;charset=utf-8';
            $xpdo = new xPDO($dsn,'root','');
            ///verifica coneccion.
          //  echo $o=($xpdo->connect()) ? 'Connected' : 'Not Connected';
            $xpdo->addPackage('trex','/Modx3/core/components/trex/model','');
    
    
    $query = $xpdo->query("select distinct NombreAviso,Ciudad,Imagen,Url from listamodelos");
    $i = 0;
    $output = '';
    //$properties = $query->toArray();
    foreach ( $query as $row){
    
    $properties['Urls'] = $row['NombreAviso'];
    $properties['Ciudads'] = $row['Ciudad'];
    $properties['NombreAvisos'] = $row['NombreAviso'];
    $properties['Imagens'] = $row['Imagen'];
    
    $output = $modx->getChunk('tplfront',$properties);
    echo $output;
    $i++;
    }