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;
}
January 4, 2016

Add a comment