This question has been answered by dubrod. See the first response.
/* ShowNews snippet */
$docId = 12; // ID of the resource holding the content and TV
$doc = $modx->getObject('modResource', docId);
if ($doc) {
if ($doc->get('published')) {
$modx->setPlaceholder('news_content', $doc->get('content'))
}
$tvValue = $doc->getTVValue('NewsImage');
if (! empty($tvValue)) {
$modx->setPlaceholder('news_image', $tvValue);
}
}
return "";
<div class="news_content">
[[+news_content]]
</div><img src="[[+news_image]]" alt="News Image">
And don't get me started on conditional output modifiers. These were created to let people who were not able to use PHP code create conditions that determined what was shown on the page. They are notoriously slow, however. Unless your server is blindingly fast, you should either learn to write simple snippets to replace your conditional output modifiers or hire someone (like me, for instance) to replace them for you.