Hi all,
I have been using MODx for several days now (really impressed), however im now a little bit stuck. Basically I have created a snippet to retrieve various template variables from templates which match a certain criteria (i.e where discipline = digital media),I am then assigning the results of the query to several arrays, these arrays in turn are being stored in several placeholders. In the template, I then want to be able to iterate through the array elements stored in the placeholder values and display the content. My end result being a dynamically populated page displaying n amount of projects. I have had a good search for an answer but to no avail im afraid, any help would be greatly appreciated.
snippet code (select_project), the value for $discipline is actually posted from a previous page
$discipline = $_REQUEST['discipline'];
$sql = "SELECT distinct contentid FROM suburb_site_tmplvar_contentvalues WHERE value='$discipline'";
$result = $modx->db->query($sql);
while($row = mysql_fetch_array($result)){
$contentid[] = $row['contentid'];
}
for($i=0; $contentid[$i]!=null;$i++){
$tvoutput = $modx->getTemplateVarOutput(array('introtext','project_title','project_copy','project_thumbnail'), $contentid[$i], 1);
$introtext[] = $tvoutput['introtext'];
$project_title[] = $tvoutput['project_title'];
$project_copy[] = $tvoutput['project_copy'];
$project_thumbnail[] = $tvoutput['project_thumbnail'];
}
$modx->setPlaceholder('introtext',$introtext[]);
$modx->setPlaceholder('project_title',$project_title[]);
$modx->setPlaceholder('project_copy',$project_copy[]);
$modx->setPlaceholder('project_thumbnail',$project_thumbnail[]);
This is the sample of code from the template
[[select_project]]
[+introtext+]
[+project_title+]
[+project_copy+]
<img src="[+project_thumbnail+]">