We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19980 ☆ A M B ☆
    • 275 Posts
    Hello
    I have an array of docs and wanted to output it by parsing a chunk
    if(count($docs)>0){
        
       $chunk = $modx->getObject('modChunk',array(
                 'name' => 'savedRequests',
            ));
        foreach ($docs as $o) { 
            if (!$chunk) return 'No line item chunk!';
            else $output .= $chunk->getContent();
            $output .=  $chunk->process($o);
            //$output .=  '<a href="[[~'.$o["id"].']]">system Id#'.$o["id"].', by '.$o["pagetitle"].'</a> <br />';
        }
      
        return $output .'<br > total: '.count($docs);
    
    }


    As you can see I have a commented line of output: $output .= '<a href="[[~'.$o["id"].']]">system Id#'.$o["id"].', by '.$o["pagetitle"].'</a>
    '; which works but parsing chunk not works because I probably don't really parse it correctly..

    Pls correct my code, thanks
      modx and ecommerce pro
      • 4172
      • 5,888 Posts
      don't know what you are trying to do with this code.

      Normally you would do it this way:

      <?php
      
      if(count($docs)>0){
           
          foreach ($docs as $o) {
              $output .=  $modx->getChunk('savedRequests',$o);
          }
          return $output .' total: '.count($docs);
      }
      
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 19980 ☆ A M B ☆
        • 275 Posts
        Thanks Bruno

        do u think yr code
        $output .=  $modx->getChunk('savedRequests',$o);

        will work faster then this:
         $output .=  '<a href="[[~'.$o["id"].']]">system Id#'.$o["id"].', by '.$o["pagetitle"].'</a> ';


        thanks
          modx and ecommerce pro