So, make a TV for your category template. Set the TV equal to the one value in your locations that matches it. That is: Monday -> %maandag%, etc...
I also assume that each location may have multiple categories? i.e. Monday, Tuesday, Nights, etc..
I can't use the same TV as is used on the locations-resources
You "could", but not recommended unless you have categories that are combinations of categories...
Open on Monday==monday||Open on Tuesday==tuesday||Open at night==night||Open in holidays==holidays
This way, it is a simple text comparison.
//Get the Request URL
$url = $_SERVER['REQUEST_URI'];
//Remove GET/POST Parameters
$pieces = explode('?', $url);
$pieces[0] = trim($pieces[0], '/');
$path = explode('/', $pieces[0]);
/*
* Checks if a Resource is a Site Alias
*/
function isSiteAlias($alias)
{ global $modx;
$c = $modx->newQuery(
'modResource',
array(
'alias'=>$alias,
array(
'template'=>4,
'OR:template'=>5,
),
'published'=>1,
)
);
$c->select(array('id','alias'));
$c->limit(25);
$c->prepare();
$matches=$modx->getCollection('modResource',$c);
foreach($matches as $res)
return $res;
}
/*
* Checks if a Resource is a Child of another Resource Id
*/
function getParentResource($alias)
{ global $modx;
$c = $modx->newQuery(
'modResource',
array(
'published'=>1,
'alias'=>$alias,
'template'=> XX //<-- Change to Category TemplateID
)
);
$c->select(array('id','alias'));
$c->limit(25);
$c->prepare();
$matches=$modx->getCollection('modResource',$c);
foreach($matches as $res)
return $res;
return -1;
}
// Initialize tracking vars
$curId = -1;
$toBaseId = -1;
$atSegment = -1;
foreach($path as $key => $segment)
{
$res = isSiteAlias($segment);
if (!empty($res))
{ if ($res->get('template') == 4)
{ $catRes = getParentResource($path[$key - 1]);
if ($catRes > -1)
{
$catVal = $catRes->getTVValue('categoryValue'); //<-- Change to Category TV
$categories = explode(',',$res->getTVValue('categories'));
if (in_array($catVal, $categories')) //<-- Change to Location TV holding Categories
{
$toBaseId = $res->get('id');
$atSegment = $key;
break;
}
}
}
else if ($res->get('template') == 5)
{
$toBaseId = $res->get('id');
$atSegment = $key;
break;
}
}
}
if ($toBaseId > -1)
{ $curId = $toBaseId;
foreach($path as $key => $segment)
{ if ($key > $atSegment)
{ $chk = isChildResource($segment, $curId);
if (!empty($chk))
$curId = $chk->get('id');
}
}
}
if ($curId > -1)
$modx->sendForward($curId);