Blog Sections Open

Redirecting to a Specific Resource with a Tiny Evolution CMS Snippet

Small redirect helpers are useful when a page should exist only as a routing entry point into the actual document tree.

The sendPage donor is a tiny example of a focused utility snippet: accept a resource ID, validate it, and redirect the request to that resource’s URL.

Example

$pid = isset($pid) ? $pid : 0;
if (!is_numeric($pid)) {
    return;
}
switch ($pid) {
    case 0:
        return;
    default:
        $modx->sendRedirect($modx->makeUrl($pid));
    break;
}

When this helps

This pattern is useful for landing nodes, shortcut pages, and controlled redirects that should still be managed from inside the CMS.

Newer post

Using mFilter with Custom Resource Output

If mFilter builds the filter form but the listing comes from another snippet, the two sides need a shared understanding of the current result set and parameters.

Older post

Implementing Basic Visitor Geotargeting in a MODX Project

Geotargeting starts as a city-detection feature, but quickly becomes a content, cache, and fallback problem if the site depends on it heavily.