We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37099
    • 338 Posts
    I should be able to do this shouldn’t I?

    $rows="";
    while($row=mysql_fetch_assoc($result)){
      $modx->setPlaceholder('firstname',$row['firstname']);
      $modx->setPlaceholder('lastname',$row['lastname']); 
      $rows .= $modx->getChunk('myRow');
    }
    
    
    $modx->setPlaceholder('rows',$rows);
    return $modx->getChunk('table');
    



    Because it’s not working for me at the moment.

    cheers
    thingstodo
      • 10487 MODX Staff
      • 1,535 Posts
      Close but not quite right - you’ll need to create an array of your various placeholders and then use $modx->parseChunk() instead to create your row output.

      Example:
      $params = array();
      $params['param1'] = 'value1';
      $params['param2'] = 'value2';
      $row = $modx->parseChunk('rowChunk', $params, '[+','+]');
      
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 37099
        • 338 Posts
        Ah i see great, thanks... so let me see if i’ve got this...

        when you getChunk in a snippet it retrieves the chunk but it doesn’t replace the placeholders there and then, that happens after the snippet has run.

        To replace placeholders of a chunk within the snippet then use parseChunk.


        Cheers
        Mike

        PS first week using modx and am very impressed so far.
          • 10487 MODX Staff
          • 1,535 Posts
          Quote from: thingstodo at Feb 23, 2009, 01:27 PM
          when you getChunk in a snippet it retrieves the chunk but it doesn’t replace the placeholders there and then, that happens after the snippet has run.

          To replace placeholders of a chunk within the snippet then use parseChunk.
          Yep, absolutely correct smiley
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com