How to include same content into a number of pages

In MODX Evo I uses a very simple tag to bring the all the content from one ID (index page) into a number of other pages so as not to copy n’paste all the time
[[IncludePage? &pageID=1]]

Is there a similar simple way in Revo or do I have to use Get Resources.

Thanks

If you have the pdoTools extra installed - you can use the pdoField snippet to grab the content of any resource:

[[pdoField? 
    &id=`1` 
    &field=`content`
]]

Or you could write your own custom snippet if you’d prefer. You could start with something like this …

Create a snippet called get-field:

<?php
// Get snippet parameters
$id = $modx->getOption('id', $scriptProperties, '');
$field = $modx->getOption('field', $scriptProperties, 'content');

// Check if ID is provided
if (empty($id)) {
    return 'Please provide the ID parameter.';
}

// Load the MODX resource
$resource = $modx->getObject('modResource', $id);

// Check if resource exists
if (!$resource) {
    return 'Could not find resource with ID ' . $id;
}

// Get the field value
$value = $resource->get($field);

// Return the field value
return $value;

Then you can call it in your templates and chunks like this:

[[!get-field? &id=`1` &field=`content`]]

You probably know this, but you can put the content in a chunk and use a chunk tag to pull it in.

Thanks all, in the end I worked it out using GetResources

[[getResources? &resources=1 &tpl=Content_tpl &includeContent=1]]

1 Like

Glad you’re sorted :+1:

With pdoTools, you can also just do this:

[[#1.content]]

. . . or use any other resource ID and any other field.

1 Like

I always forget about that! :person_facepalming: