diff --git a/course/renderer.php b/course/renderer.php index 9d1439c7ad8..ba33b0647b8 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -372,13 +372,14 @@ class core_course_renderer extends plugin_renderer_base { $inputsize = 30; } - $data = (object) [ - 'searchurl' => (new moodle_url('/course/search.php'))->out(false), - 'id' => $formid, - 'inputid' => $inputid, - 'inputsize' => $inputsize, - 'value' => $value - ]; + $data = new stdClass(); + $data->searchurl = \core_search\manager::get_course_search_url()->out(false); + $data->id = $formid; + $data->inputid = $inputid; + $data->inputsize = $inputsize; + $data->value = $value; + $data->areaids = 'core_course-course'; + if ($format != 'navbar') { $helpicon = new \help_icon('coursesearch', 'core'); $data->helpicon = $helpicon->export_for_template($this); diff --git a/course/search.php b/course/search.php index 9dcd11292a2..144767d452f 100644 --- a/course/search.php +++ b/course/search.php @@ -24,6 +24,7 @@ require_once("../config.php"); require_once($CFG->dirroot.'/course/lib.php'); +$q = optional_param('q', '', PARAM_RAW); // Global search words. $search = optional_param('search', '', PARAM_RAW); // search words $page = optional_param('page', 0, PARAM_INT); // which page to show $perpage = optional_param('perpage', '', PARAM_RAW); // how many per page, may be integer or 'all' @@ -31,6 +32,11 @@ $blocklist = optional_param('blocklist', 0, PARAM_INT); $modulelist= optional_param('modulelist', '', PARAM_PLUGIN); $tagid = optional_param('tagid', '', PARAM_INT); // searches for courses tagged with this tag id +// Use global search. +if ($q) { + $search = $q; +} + // List of minimum capabilities which user need to have for editing/moving course $capabilities = array('moodle/course:create', 'moodle/category:manage'); diff --git a/course/templates/course_search_form.mustache b/course/templates/course_search_form.mustache index d709096c015..f8ec18620ca 100644 --- a/course/templates/course_search_form.mustache +++ b/course/templates/course_search_form.mustache @@ -17,22 +17,27 @@ {{! @template core_course/course_search_form - This template renders the search form. + This template renders the form for course search. Example context (json): { - "searchurl": "https://domain.example/course/search.php", + "searchurl": "https://moodlesite/course/search.php", "id": "coursesearch", "inputid": "coursesearchbox", - "inputsize": "30", - "value": "Find in course", - "helpicon": "" + "inputsize": 30, + "value": "certificate", + "name" : "q", + "helpicon": [{ + "heading": "Search courses", + "text": "You can search for multiple words at once and can refine your search as follows:" + }] } }}