Does anyone know if there’s a reason the Document Library doesn’t by default have a getSearchableContent
function, and therefore isn’t included in the page search index?
I’m wondering if it’s a performance concern, or whether it’s just not something that’s been considered.
I whipped up a solution for this earlier via an override, which looks like this:
<?php
namespace Application\Block\DocumentLibrary;
use Concrete\Block\DocumentLibrary\Controller as DocumentLibraryBlockController;
use Concrete\Core\File\File;
use Concrete\Core\File\FolderItemList;
class Controller extends DocumentLibraryBlockController
{
public function getSearchableContent()
{
$list = new FolderItemList();
$list = $this->setupFolderFileSetFilter($list);
$list = $this->setupFolderFileFolderFilter($list);
$list->ignorePermissions();
$list->setItemsPerPage(100000);
$list = $this->setupFolderAdvancedSearch($list);
$pagination = $list->getPagination();
$results = $pagination->getCurrentPageResults();
$output = '';
foreach($results as $f) {
if ($f instanceof \Concrete\Core\Tree\Node\Type\File) {
$fileID = $f->getTreeNodeFileID();
} else {
$fileID = $f->getTreeNodeID();
}
$file = File::getByID($fileID);
if ($file) {
$output .= $file->getTitle() . ' ' . $file->getDescription() . ' ';
}
}
return $output;
}
}