Hello,
My Goal: intercept requests for top-level URLs (/something, not /parent/child) that do not exist in SS. When one is found, have SS query a different data store to see if content exists for the given URL. If it does, render the content. If not, resume normal SS request processing (i.e. a file not found error should be displayed).
Question: is this (below) a good way to implement this functionality?
Thank you,
Ben
In Page.php's Page_Controller:
public function handleRequest(HTTPRequest $request) {
$this->pushCurrent();
$params = $request->allParams();
$urlsegment = $params['URLSegment'];
$response = parent::handleRequest($request);
if ($response->getStatusCode() == 404 && (!empty($urlsegment) && $consultant = DataObject::get_one('ConsultantModel', 'URLKey = "' . Convert::raw2SQL($urlsegment) . '"'))) {
$response = $this->renderWith(array("Consultant", "Page"), $consultant);
}
$this->popCurrent();
return $response;
}