Skip to content

Instantly share code, notes, and snippets.

@karlhinze
Last active February 10, 2017 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlhinze/12ea065d42aca8007792f1857f62b582 to your computer and use it in GitHub Desktop.
Save karlhinze/12ea065d42aca8007792f1857f62b582 to your computer and use it in GitHub Desktop.
A custom module for LiveWhale: easy global searches by ID
<?php
$_LW->REGISTERED_APPS['global_search']=array( // configure this module
'title'=>'Global Search',
'handlers'=>array('onLoad')
);
class LiveWhaleApplicationGlobalSearch {
public function onLoad() { // in back-end search, if admin searching for ID, automatically search globally
global $_LW;
if ($_LW->page=='search') {
if (!empty($_LW->_GET) && array_key_exists('search',$_LW->_GET)) {
if ($_LW->userSetting('core_admin')) {
if (preg_match('~^[0-9]+$~', $_LW->_GET['search'])) {
$_LW->_GET['group_mode'] = 1; // show from all groups
$_LW->_GET['results'][] = 2; // search shared content
$_LW->_GET['results'][] = 5; // show non-hidden content
}
}
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment