Adding source tag to url

Maybe a silly question.
I want to make a webpage only accessible by scanning a qr-code.
One of the things I need to have is a page with a url like /mypage,html?source=qr

Where can I change the setting that I can add that tag? Because now I’m not allowed to do that.
Is it even possible to make pages/url’s with a tag in MODX?

Hope someone can help me out here.

[Edited to better answer your question]

Untested - but something like this might be worth a try.

Create a snippet called checkQR:

<?php
if (isset($_GET['source']) && ($_GET['source'] == "qr") ) {
    // DO NOTHING [will show page normally]
} else {
    // REDIRECT TO SOMETHING ELSE
    header('Location: [[~1]]'); 
}

Then in the page you want to protect [or in the template / chunk etc] - call the snippet:

[[!checkQR]]

Then,

yourdomain.com/page.html?source=qr

should work. If the source attribute is absent or wrong - you should get redirected.

2 Likes

You can add arbitrary request parameters (?source=qr) to every MODX page URL.
MODX always loads the page /mypage.html and you can then process the GET request parameters with a snippet (as @dejaya explained).


There’s also the MODX function sendRedirect that can be used to redirect to another page.

2 Likes

It works perfect!
Thank you. Learning every day.

It works perfect! Thank you.
Learning every day

1 Like