RamblingRoss
The blog of Ross Fruen, a .NET consultant

Improve search functionality in sites hosted by Stacey

The Stacey 3.0.0 CMS provides the ability to search for text within pages making up the website it generates.

By default this functionality is limited to the fields 'url' 'file_path', 'title', 'author' and 'content'

For sites that make use of additional fields, any content within them is not included within a search. To make all text available to search, filtering within the create_full_cache function needs to be removed.

To achieve this open the /app/cache.inc.php file, navigate to the create_full_cache() function, remove the $search_fields variable and the loop that removes entries form the $current_page collection when their key is not present in $search_fields.

A modified version of the function follows:

static function create_full_cache($pages = null) {
$store = array();
if (!isset($pages)) $pages = Helpers::file_cache('./content');
foreach ($pages as $page) {
if ($page['is_folder']) {
$current_page = AssetFactory::get($page['path']);
# Skip for password protected pages
if (isset($current_page['password_protect']) || isset($current_page['hide_from_search'])) continue;

$store[] = $current_page;
$children = self::create_full_cache(Helpers::file_cache($page['path']));
if (is_array($children)) $store = array_merge($store, $children);
}
}
return $store;
}

Add a comment

If you want your comment to appear on this page please complete the form below. Your name and email address are optional, although the latter will be required if you want a response. Your email address will not appear against your comment and will only be used to correspond with yourself (where appropriate).

Thanks!

Thank you for submitting your comment, it will appear here after moderation is complete.

Sorry

There was a problem sending your comment, please try again.