Place this snippet in your default homepage
<!--?php $from = $_SERVER['HTTP_REFERER']; // note, $_SERVER anything can be forged if (strpos($from, 'facebook.com') !== false) { $id = 12; // id of campaign page to be displayed $url = $modx--->makeUrl(); $modx->sendRedirect($url); } if (strpos($from, 'google.com') !== false) { $id = 14; // id of campaign page to be displayed $url = $modx->makeUrl(); $modx->sendRedirect($url); }
I think what you may want is donshakespeare's code, but with $modx->sendForward($id), instead of sendRedirect(). The sendForward method will keep the URL the same and will "pull in" the full content of the page specified. Note that it will use the template and template variable values of the page being pulled in, not the current page.
You won't need makeUrl() because sendForward() takes a resource ID as its argument.
$tvId = 2;
$persona = "facebook"; //this will come from a cookie value
/* Get the records from the database that match this page slug */
$query = $modx->newQuery('modTemplateVarResource', array(
'value' => $modx->resource->GetTVValue($tvId), // get the other pages that match this page
'tmplvarid' => $tvId,
));
$pages = $modx->getCollection('modTemplateVarResource', $query);
foreach($pages as $page)
{
// get the resource object for this relationship
$page = $modx->getObject('modResource', $page->contentid);
$page_persona = $page->getTVValue(1);
// if this resources persona matches the current user's persona, and we're not already viewing the page we should be
if ($page_persona == $persona && $page->id != $modx->resource->id) {
$modx->sendForward($page->id);
}
}