Passing the querystring to a MIGX custom manager page in MODX

23rd October 2013

We were developing a reservation system with a number of CMPs all relating to the same set of client data. From the bookings CMP we needed the ability to view the individual guests' details for that reservation. We added a column with a link to the guests CMP but then we hit a hitch. The querystring isn't available to the getlist processor. As with everything MODX, there's likely to be another way to do this, but here's our solution.

To get around this, we added some code to the /assets/components/migx/connector.php file after line 34:

$referrer= $_SERVER['HTTP_REFERER'];
$referrer = str_replace("&","&",$referrer);
parse_str($referrer);
if(isset($bookingid)) $_POST['bookingid']=$bookingid;

This chunk of code takes the querystring and sets a $_POST value with our bookingid value. This value is then available to the getlist.php processor. This needs an edit to work with our bookingid but rather than edit the default, we duplicated it, using processorspath in the MIGX-dbsettings tab to define the location of it.

From the standard code (line 58-59):

$where = !empty($config['getlistwhere']) ? $config['getlistwhere'] : '';
$where = $modx->getOption('where', $scriptProperties, $where);

We changed this to:

$bookingID = $modx->getOption('bookingid', $scriptProperties, '');

if($bookingID=='') {
 $where = !empty($config['getlistwhere']) ? $config['getlistwhere'] : '';
 $where = $modx->getOption('where', $scriptProperties, $where);
} else {
 $where='{"bookingid:=":"'.$bookingID.'"}';
}

And there you have it, a MIGX CMP which shows only the set of data we're after.


Empowering causes with the means to directly impact lives

B Corporation Certified Escape the City 100 Winner We plant trees with Ecologi for every project we complete
Registered office address
86-90 Paul Street, London,EC2A 4NE

SIGN UP FOR EMAILS

Hit up our positive impact newsletter to receive some good news in your inbox.

"*" indicates required fields

*
This field is for validation purposes and should be left unchanged.

© Copyright 2023 Studio Republic