<?php
$output = '';
$sql = $modx->db->query('SELECT * FROM havainto where havainto="' . $modx->documentObject['pagetitle'] . '" ORDER BY date DESC ');//define the DB query, in this case the table is named 'havainto', add WHERE AND etc. as needed
$resultArray = $modx->db->makeArray( $sql );//put it into an array
foreach($resultArray as $item)//go through each record in the array
{//start looping through the data array
$params['aika']=$item['date'];//set the placeholders, the $params sets the name of the placeholder, the $item is the column name from the DB table
// $params['havainto']=$item['havainto'];
$params['maara']=$item['maara'];
$params['bongaaja']=$item['nimi'];
$params['paikka']=$item['paikka'];
$output.=$modx->parseChunk('naytaHavaintoTpl', $params, '[+', '+]');//define the chunk name and process the content, here it's naytaHavaintoTpl which has the placeholders for the data
}//finish looping through the data array
return $output;//now return the output from the processed chunk
?><p>[+aika+] <strong>[+havainto+]</strong> [+maara+] kpl, [+bongaaja+], [+paikka+]</p>
This question has been answered by multiple community members. See the first response.
[[!lintuHavainnot]]
[[+...]]
$params, '[+', '+]'); -> $params, '[[+', ']]');
Thanks! It's still not working.this means?
[[!Rowboat?
&table=`havainto`
&tpl=`naytaHavaintoTpl`
&columns=`{"date":"aika","maara":"","nimi":"bongaaja","paikka":""}`
&limit=`10`
&where=`{"havainto:=":"[[*pagetitle]]"}`
&sortBy=`date`
&sortDir=`DESC`
]]