Set up a search-box (textfield/html) to search content within a specific course?

Re: Set up a search-box (textfield/html) to search content within a specific course?

by Stefan Joller -
Number of replies: 3

We found a solution for this problem - you can add a label with a search box, that searches only within a certain course, using the follwoing html code:


<form class="search-input-form expanded" action="https://YOURMOODLEURL/search/index.php"><label for="id_q_XXXXX" class="accesshide">Search</label><input type="text" filter="course: coursename" name="q" placeholder="Search" size="13" tabindex="-1" id="id_q_XXXXX"
        class="form-control">
    <input type="hidden" name="context" value="2"> <input type="hidden" name="courseids" value="insert id-number of course">

</form>

Average of ratings: Useful (2)
In reply to Stefan Joller

Re: Set up a search-box (textfield/html) to search content within a specific course?

by Eoin Campbell -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
This is a great idea, especially for courses with a lot of material. I have published a Generico filter that you can use to insert this HTML fragment into any course, see Re: Generico Showcase (in-course search box) for details.
Average of ratings: Useful (3)
In reply to Eoin Campbell

Re: Set up a search-box (textfield/html) to search content within a specific course?

by Luis de Vasconcelos -
Thanks. This looks very interesting! smile
In reply to Stefan Joller

Re: Set up a search-box (textfield/html) to search content within a specific course?

by Dennis Verdonck -
I tried to put this code in the HTML of a Label, but it doens't work.
what does I have to fill in for the "XXXXX"?

Thanks !