<div class="section-gray" id="news"> <div class="container"> <div class="title"> <h2> HERE COMES THE PAGETITLE </h2> </div> <h4 class="description"> HERE COMES THE DESCRIPTION </h4> <div class="row"> <div class="col-md-4 col-sm-6"> <div class="blog"> <div class="body text-center"> <div class="introtext"> <p> HERE COMES THE INTROTEXT </p> </div> <div class="content"> HERE COMES THE CONTENT </div> </div> </div> </div> </div> </div> </div>
This question has been answered by BobRay. See the first response.
[[!GetNewsPlaceholders]]
[[+news_description]] [[+news_introtext]] [[+news_content]]
<?php
$docId = $modx->getOption('news_page');
$doc = $modx->getObject('modResource', (int) $docId);
if (! $doc) {
$modx->log(modX::LOG_LEVEL_ERROR, 'Could not get resource with ID: ' . $docId);
} else {
$placeholders = array('description', 'introtext', 'content');
foreach ($placeholders as $ph) {
$modx->setPlaceholder('news_' . $ph, $doc->get($ph));
}
}
return '';
[[getResourceField? &id=`71` &field=`introtext`]]
[[getResourceField? &id=`71` &field=`description`]]
[[!getIntroText? &id=`67`]]
[[!getdescription? &id=`67`]]
"Create a System Setting with the key: news_page and put the ID there."
[[+news_description]] [[+news_introtext]] [[+news_content]]
[[!GetMyChunk? &chunk=`Chunk1` &docId=`69`]] [[!GetMyChunk? &chunk=`Chunk2` &docId=`70`]] [[!GetMyChunk? &chunk=`Chunk3` &docId=`71`]]
<?php
$chunk = $modx->getOption('chunk', $scriptProperties, '', true);
$docId = $modx->getOption('docId', $scriptProperties, '', true);
if (empty($chunk) || empty($docId)) {
return 'Empty Property';
}
$doc = $modx->getObject('modResource', (int) $docId);
if (! $doc) {
return 'Resource ' . $docId . ' not found';
}
$fields = $doc->toArray();
return $modx->getChunk($chunk, $fields);
[[GetMyChunks]] [[+Chunk1_placeholder]] [[+Chunk2_placeholder]] [[+Chunk3_placeholder]]
<?php
$output = '';
/* Array of chunk names and associated Doc ID.
Name must match the first part of the
placeholder exactly */
$chunks = array(
'Chunk1' => 69,
'Chunk2' => 70,
'Chunk1' => 71,
);
foreach ($chunks as $chunkName => $docId) {
$fields = array();
/* Get the resource */
$doc = $modx->getObject('modResource', $docId);
/* Make sure we got it */
if (! $doc) {
$output .= '<br>Resource ' . $docId . ' not found';
} else {
/* Get Resource's fields into an array for getchunk */
$fields = $doc->toArray();
/* Get chunk with placeholders replaced by field values*/
$chunkContent = $modx->getChunk($chunkName, $fields);
/* Set the chunk's specific placeholder */
$modx->setPlaceholder($chunkName . '_placeholder', $chunkContent);
}
}
/* return nothing (hopefully) or any errors */
return $output;