【发布时间】:2016-02-27 19:16:57
【问题描述】:
我正在尝试将搜索结果返回到新控制器,而不是执行搜索操作的位置。问题是Results 永远无法从CustomSearchResultPage.ss 访问。我已经为我认为正在发生的事情添加了内联 cmets,我的想法是否正确?
// Customise content with results
$response = $this->customise(array(
'Results' => $results ? $results->getResults() : '',
));
if ($results) {
$response = $response->customise($results);
}
// Use CustomSearchResultPage.ss template
$templates = array('CustomSearchResultPage', 'Page');
// Create a new CustomSearchResultPage page
$page = CustomSearchResultPage::get_one('CustomSearchResultPage');
// Build a controller using the CustomSearchResultPage
$controller = CustomSearchResultPage_Controller::create($page);
// Add the custom data to the newly minted controller
$result = $controller->customise($response);
// Return the controller and tell it how to render
return $result->renderWith($templates);
页面似乎按预期呈现,只是变量始终为空......
【问题讨论】:
标签: php silverstripe