You could do this easily with a custom Snippet. As BobRay said, there are lots of ways to do this sort of thing in MODX.
Using Frogabog's example:
Make a TV with the Chunk Name (we'll call it 'myspecialchunk')
Make a Snippet with the following code:
$name = $modx->resource->getTVValue('myspecialchunk');
if (!empty($name))
return $modx->getChunk($name, array());
return;
Going further with Frogabog's example:
$id = empty($id)
? 1 // <-- Some default resource
: $id;
if ($id > 0)
{ $resource = $modx->getObject('modResource', $id);
if (!empty($resource))
{ $name = $modx->resource->getTVValue('myspecialchunk');
if (!empty($name))
$output = $modx->getChunk($name, array());
}
}
return $output;
Alternatively, you could also make a Snippet to just get the content of the Resource
$id = empty($id)
? 1 //<--- set this to a default Resource ID
: $id;
$output = 'Some default output';
if ($id > 0)
{ $resource = $modx->getObject('modResource', $id);
if (!empty($resource))
$output = $resource->get('content');
}
return $output;
Lots'o'ways!!
[ed. note: fuzzicallogic last edited this post 14 years, 2 months ago.]