Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
$212 per month—let's make that $500!Learn more
Forwards the request to another resource without changing the URL. If the ID provided does not exist, sends to a 404 Error page.
API Doc: modX::sendForward()
void sendForward (integer $id, [string|array $options = null], [boolean $sendErrorPage = true])
$idis a Resource ID (you cannot sendForward to an URL - if you need to pass some value, use
modX::setPlaceholderand call that on the target resource).
$optionsis assumed to be a proper HTTP response code when it is a string, eg "HTTP/1.1 301 Moved Permanently". If it's an array, you can use the following options:
response_code: response code, please see example below
error_type: response code type, please see example below. F.e. 404
error_header: "Header:" value
error_pagetitle: error pagetitle value
error_message: error message
merge: a way to merge the resource currently in
$modx->resourcewith the target resource. The
_processedvalues are excluded as well as the value of the 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.
$sendErrorPageWhether we should skip the sendErrorPage if the resource does not exist.
Send the user to Resource ID 234 without actually changing the URL.
$options = array( 'response_code' => '404 Not Found', 'error_type' => '404', 'error_header' => '404 Not Found', 'error_pagetitle' => 'Error 404: Page not found', 'error_message' => '<h1>Page not found</h1><p>The page you requested was not found.</p>' ); $this->sendForward($this->getOption('error_page', $options, $this->getOption('site_start')), $options, false);