Why wont this work?
I want the chunk to have access to all fields in the db.
$modx->runSnippet('DBconnect');
$query = "SELECT * FROM modx_site_content ORDER BY menuindex";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$output .= $modx->getChunk("printModel",$row->toArray() );
}
return $output;
The chunk is
<a href="#">[[+longtitle]]</a>
[ed. note: johnjohn22 last edited this post 14 years ago.]
____________________________________________________
What version of MODx are you using?
Oh, forgot that: Revolution
____________________________________________________
toArray() operates on xPDO objects and you're not using xPDO. You could switch to xPDO, but have you tried just sending $row, instead of $row->toArray()?
The xPDO version would look like this:
<?php
$c = $modx->newQuery('modResource');
$c->sortby('menuindex','ASC');
$docs = $modx->getCollection('modResource', $c);
foreach ($docs as $doc) {
$output .= $modx->getChunk("printModel",$doc->toArray() );
}
return $output;
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
Hi Bob, just sending $row works nice. Thanks!
____________________________________________________
Glad it worked. The xPDO version would give you the option of using getIterator() instead of getCollection() (same args). It might or might not speed things up and it would use less memory.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html