Global Navigation

header

Main Navigation

Sub-Navigation

Content

 

DB query and Placeholders for the MODx Wiki

Custom table snippet with custom placeholders.
To access a custom table you have in your MODx database from a snippet and use some custom placeholders to render the output. Create a new snippet to call on your page:

<?php
$output = '';
$sql = $modx->db->query( 'SELECT * FROM `tblprojects` LIMIT 0, 1000');
$resultArray = $modx->db->makeArray( $sql );
foreach($resultArray as $item)
$params['award']=$item['Grant_Award'];
$params['ref']=$item['Project_Ref'];
$params['area']=$item['LA_Area'];
$output.=$modx->parseChunk('ProjectTpl', $params, '[+', '+]');
}
return $output;
?>

Full wiki article is here.

modx

Footer