Is there a way to display the search box in the middle of the front page?
(google style..)
Do you mean a certain database activity search box on your Moodle site front page?
i wasn't sure what i mean
but eventualy, i used a label field, used HTML to create a search form
and submit button, and sent the "search values" to query.php, to the global search
works fine, and now i have a nice "global" search in the middle of the page, google style...
Itamar:
What I want is to have that search (advanced search of a database activity) either in the front/course page but, preferably, in the "My Moodle" page of all users. Is it possible? And if possible, does it work on both Moodle 1.9.x and Moodle 2.x?
You can't get the search form out but you can replicate it anywhere with a bit of html and javascript such that the search button of the replicate takes the values from the input fields, constructs the url for the database list view with the search parameters and sets the location.href to open the database page.
The structure of the url can be easily figured out from playing with the advanced search of the designated database activity.
You should be able to place this html+javascript form in an html block and stick the block to the My Moodle page.
Of course, the database activity should be accessible to all users.
Afaict, if this approach works, it should work in both 1.9 and 2.0.
hth
Itamar: Thank you for your help.
I am going to try that and post the solution here (if I anage to achieve it, hehe)
I realize this post is pretty old, but I would LOVE to achieve what you've described here.
Putting the search from a database activity on the front page.
Itamar, your response about how to create the url for the advanced search is a little cryptic to me - I'm new in php, but still having a hard time figuring out how to do this.
Could you perhaps explain in more detail how to create the search?
Your responses are most helpful!
Do you want to implement it in php or just html + js?
If the latter then you just have to understand how the search url is constructred and create your own html form to denerate that url.
For example, if you run the following search in demo features
the generated url is
http://demo.moodle.net/mod/data/view.php?d=2&mode=list&perpage=10&search=&sort=0&order=ASC&advanced=0&filter=1&advanced=1&f_4=&f_5=hello&u_fn=john&u_ln=doh
You can see that the search sends the fields from the form with their content to mod/data/view.php?d=2&mode=list.
If you prefer php you should probably look into writing a designated block. You should also look into the data lib function that prints the search form to see how it can serve your purpose. hth
Okay so I've been reviewing this option....which I did get to work. I've created a link that you can click, and you are redirected to a "list view" of your search results within the database activity. Cool.
What I would like more, is to redirect to a "single page view". And the only real way to do THAT is to have the $rid of the entry.
Right now I believe the only way this is possible, is to grab all the entries within my database activity through a sql call. Do my OWN search for an entry and THEN grab it's $rid. And finally, make my link to the "single view" of the entry I want.
Honestly I'm not too sure how to do that correctly....and it seems like lot of extra work. Am I overthinking this? Would there be an easier way?
You can add a search box anywhere by adding and HTML block. You must add an HTML block, then add HTML code that has the search form content in the HTML markup. Here is how I did it:
<form id="coursesearch" action="http://45.55.221.247/moodle/course/search.php" method="get"><fieldset class="coursesearchbox invisiblefieldset" id="yui_3_17_2_1_1470765375163_153"><label for="shortsearchbox" id="yui_3_17_2_1_1470765375163_154">Search courses: </label><input type="text" id="shortsearchbox" size="12" name="search" value=""><input type="submit" value="Go"></fieldset></form>
Then click Save.
I used the following CSS to customize my search elements:
---------
#page .block-region .block .header {
background: #5dc766;
}
---------
input[type="color"], .uneditable-input {
background-color: #eee;
border: 1px solid #5d5656;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
-webkit-transition: border linear .2s, box-shadow linear .2s;
-moz-transition: border linear .2s, box-shadow linear .2s;
-o-transition: border linear .2s, box-shadow linear .2s;
transition: border linear .2s, box-shadow linear .2s;
}
-----
Thank you so much John Moore
your code is working fine but in my moodle, I have to change only one thing that is fieldset to div. but there are one issue I cant be able to include the (id="yui_3_17_2_1_1470765375163_153 and 154") in the div and label.
my moodle version is 2.7
your code after edited is as
<form id="coursesearch" action="our_website_address/course/search.php" method="get">
<div class="coursesearchbox invisiblefieldset">
<label for="shortsearchbox">Search courses: </label>
<input type="text" id="shortsearchbox" size="12" name="search" value="">
<input type="submit" value="Go">
</div>
</form>
We can use this small code also to get search result:
<form action="our_website_address/course/search.php" method="get">
<input type="text" id="shortsearchbox" name="search">
<input type="submit" value="Go">
</form>