So, I think what I am trying to do should be simple… But it’s giving me some serious headaches! I created a Knowledge Base that has individual topics (dataobjects with links) and release notes (dataobjects without links). Currently my site filter works great with the topics. I can search for a title with partial match, and link to the page with ease, because each topic has a unique url. HOWEVER… I want to add the release note titles into my search, but I would need to link to their parent page, I cannot seem to get this working correctly.
My working code is:
public function index(HTTPRequest $request){
$topics = Topic::get();
if ($search = $request->getVar('Keywords')) {
$topics = $topics->filter(array(
'Title:PartialMatch' => $search
));
}
$paginatedTopics = PaginatedList::create(
$topics,
$request
)
->setPageLength(10)
->setPaginationGetVar('s');
return [
'Results' => $paginatedTopics
];
}
This changed code seems to break the whole thing:
public function index(HTTPRequest $request){
$topics = Topic::get();
$rnotes = ReleaseNote::get();
$list = new ArrayList();
$list->merge($topics);
$list->merge($rnotes);
if ($search = $request->getVar('Keywords')) {
$list = $list->filter(array(
'Title:PartialMatch' => $search
));
}
$paginatedTopics = PaginatedList::create(
$list,
$request
)
->setPageLength(10)
->setPaginationGetVar('s');
return [
'Results' => $paginatedTopics
];
}
Any idea what I am doing wrong?