How to let your client preview a page when the site is offline, without being logged in. This tip comes from the Sepia River Blog, via donshakespeare in a Slack conversation.
neoneddy asked...
Anyone know of a good way to share a preview URL in MODx without its being public?
The Solution:
sepiariver says...
For a "quick-and-dirty" method, use a plugin:
if ($modx->context->get('key') === 'mgr') return; switch ($modx->event->name) { case 'OnHandleRequest': if ($_GET['my-secret-get-var'] === 'my-secret-value') $modx->config['site_status'] = 1; break; default: break; }
What's the Story?
The best place for a full explanation of what this does is the Sepia River blog post.
Basically, you give the client a link to the page including a specific request variable. When that URL is requested, it's checked to see if it has the correct variable, and if it does, the site_status setting is temporarily set to 1 - the site is taken online just for that page request.
P.S. Don't forget to check the OnHandleRequest checkbox in the plugin's System Events tab!