diff --git a/en/extending-modx/modx-class/reference/modx.sendforward.md b/en/extending-modx/modx-class/reference/modx.sendforward.md index 13618cd82..7bb156b36 100644 --- a/en/extending-modx/modx-class/reference/modx.sendforward.md +++ b/en/extending-modx/modx-class/reference/modx.sendforward.md @@ -25,15 +25,15 @@ void sendForward (integer $id, [string|array $options = null], [boolean $sendErr - `merge`: a way to merge the resource currently in `$modx->resource` with the target resource. The `content`, `pub_date`, `unpub_date`, `richtext`, `_content` and `_processed` values are excluded as well as the value of the [forward_merge_excludes](building-sites/settings/forward_merge_excludes) system setting. I'm not sure if this is supposed to be used out of the core and there's probably better ways to get data combined (eg: `setPlaceholder`) then merging. - `$sendErrorPage` Whether we should skip the [sendErrorPage](extending-modx/modx-class/reference/modx.senderrorpage "modX.sendErrorPage") if the resource does not exist. -## Example +## Examples -Send the user to Resource ID 234 without actually changing the URL. +1. Send the user to Resource ID 234 without actually changing the URL. ``` php $modx->sendForward(234); ``` -Send user to 404 Error page, for actual page ID we use [error_page](building-sites/settings/error_page) system setting value. If there is no such value, +2. Send user to 404 Error page, for actual page ID we use [error_page](building-sites/settings/error_page) system setting value. If there is no such value, the value of [site_start](building-sites/settings/site_start) will be used. ``` php @@ -46,6 +46,19 @@ $options = array( ); $this->sendForward($this->getOption('error_page', $options, $this->getOption('site_start')), $options, false); ``` +3. Show replacement page, keeping original `pagetitle`, `introtext` and other fields. To do this, you just need to specify an additional array with keys: + +``` php +$options = array( + 'merge' => 1, // field gluing mechanism enabled + // original fields list that need to be excluded from the result + 'forward_merge_excludes' => 'id,template,type,published,class_key' +); +$this->sendForward(15, $options);; +``` +[forward_merge_excludes](building-sites/settings/forward_merge_excludes) setting manages source page fields that need to be excluded from the results. Next fields will definitely be added as well: `content,pub_date,unpub_date,richtext` + +This is good approach if you want hide/protect some resources but left `pagetitle` and `description` for visitors and search crawlers. ## See Also @@ -55,3 +68,4 @@ $this->sendForward($this->getOption('error_page', $options, $this->getOption('si - [modX.sendErrorPage](extending-modx/modx-class/reference/modx.senderrorpage "modX.sendErrorPage") - [modX.sendUnauthorizedPage](extending-modx/modx-class/reference/modx.sendunauthorizedpage) - [error_page](building-sites/settings/error_page) +- [forward_merge_excludes](building-sites/settings/forward_merge_excludes)