$messages = $modx->getCollection('modUserMessage'); $output = ''; foreach ($messages as $message) { $fields = $message->toArray(); $output .= $modx->getChunk('messageTpl', $fields); } return $output;
<p>[[+id]] -- [[+subject]] -- [[+message]]</p>
foreach ($messages as $message) { /** @var $message xPDOObject */ $fields = $message->toArray ('', true); $query = $modx->newQuery('modUser', array( 'id' => $fields['sender'], )); $query->select('username'); $username = $modx->getValue($query->prepare()); $fields['sender'] = $username; $fields['class'] = $fields['read']? 'read' : 'unread'; $fields['read'] = $fields['read'] ? 'Yes' : 'No'; $inner .= $modx->getChunk($tpl, $fields); }
$output = ''; foreach ($messages as $message) { /** @var $message xPDOObject */ $fields = $message->toArray ('', true); $query = $modx->newQuery('modUser', array( 'id' => $fields['sender'], )); $query->select('username'); $username = $modx->getValue($query->prepare()); $fields['sender'] = $username; $fields['class'] = $fields['read']? 'read' : 'unread'; $fields['read'] = $fields['read'] ? 'Yes' : 'No'; $output .= $modx->getChunk('messageTpl', $fields); }; return $output;
$output = ''; foreach ($messages as $message) { /** @var $message xPDOObject */ $fields = $message->toArray ('', true); $query = $modx->newQuery('modUser', array( 'id' => $fields['sender'], )); $query->select('username'); $username = $modx->getValue($query->prepare()); $output .= $username . ' '; }; return $output;
$messages = $modx->getCollection('modUserMessage');
$output = ''; $messages = $modx->getCollection('modUserMessage'); foreach ($messages as $message) { /** @var $message xPDOObject */ $fields = $message->toArray ('', true); $query = $modx->newQuery('modUser', array( 'id' => $fields['sender'], )); $query->select('username'); $username = $modx->getValue($query->prepare()); $fields['sender'] = $username; $fields['class'] = $fields['read']? 'read' : 'unread'; $fields['read'] = $fields['read'] ? 'Yes' : 'No'; $output .= $modx->getChunk('messageTpl', $fields); }; return $output;
$query->sortby('date_sent', 'DESC');