Search MoodleDocs Block

Search MoodleDocs Block

by Darren Smith -
Number of replies: 20

Add this simple block to allow your moodle users to search the documentation project site (using google) from your moodle install. Credits and the like are in the file.

Installation: Go inside of your blocks folder, create a new folder called searchdocs and drop the attached file inside. Log into your moodle installation using an admin account and go to your admin page to trigger the install process. Add the block to a course like you would add any other block.

Have fun and I hope somebody out there finds it useful.

Darren

Average of ratings: -
In reply to Darren Smith

Re: Search MoodleDocs Block

by Matt Gibson -
Cheers Darren - I'll give this a try. It seems to install fine apart from this strange string at the top of the admin screen:

Content-Disposition: Attachment Content-Disposition: Attachment Content-Disposition: Attachment

not sure how to do a screen shot or i would. Is this related? or the result of some other fiddling of mine (half-finished postgres enhmessage hack install)?

Mattodd admin screenshot (text at top)
In reply to Matt Gibson

Re: Search MoodleDocs Block

by Darren Smith -
Actually I did see that error message when I was setting the thing up and playing about with it. I deleted the block (from the admin page) and it's folder and reinstalled a clean version and it went away. I thought it was something that I had caused earlier but obviously it is in the most recent file.

I shall have a look at this when I get a chance.

Darren
In reply to Darren Smith

Re: Search MoodleDocs Block

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Darren,

Thanks for the block - it's great! approve

It seems that the error message Matt mentions comes from the first three lines of block_searchdocs.php (not sure how they got there thoughtful), anyway please find attached replacement file without these lines, which works perfectly!
In reply to Helen Foster

Re: Search MoodleDocs Block - Fixed!

by Darren Smith -
That's strange. Thanks for looking into this, Helen. smile

Darren
In reply to Darren Smith

Re: Search MoodleDocs Block

by Bryan Williams -
Hey Darren, this is a nice addition to Moodle and should be included in the 1.6 release IMO. Can you adjust your code so a new browser is opened when the Google search is run, so the user isn't taken away from the course environment.
In reply to Bryan Williams

Re: Search Moodle Docs Block

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Bryan,

Please find attached version which opens in a new browser window.
In reply to Helen Foster

Re: Search Moodle Docs Block

by Bryan Williams -
Thanks Helen. One more little thing on this block; can you also make the "MoodleDocs" link open another browser instance?
In reply to Bryan Williams

Re: Search MoodleDocs Block

by David Scotson -

The way that Google site search is integrated with the Moodle.org is quite nice, as a way of remaining within Moodle environment without having to pop up a new window. Is something similar possible with this block?

Example results for 'google' on Moodle.org sitesearch

In fact, I notice that changing the end of that URL to docs.moodle.org or docs.moodle.org/en narrows the results nicely. Maybe that could be added as a third search option along with 'Web' and 'Moodle.org'

In reply to David Scotson

Re: Search MoodleDocs Block

by Darren Smith -
That's an interesting thought. I actually took out the radio button to keep things simple.

I'm all for having search results in the moodle.org style as found on this site's homepage if somebody could give me a starting point. I did search the forums but couldn't find the solution.

Darren
In reply to David Scotson

Re: Search MoodleDocs Block

by Jan Dierckx -

Why not use the search facility of the moodle docs directly instead of using Google?

See this post

In reply to Jan Dierckx

Re: Search MoodleDocs Block

by Andrew Walker -
I thought it might be time I learnt how to write a block smile

So I've attached a modified version of this that adds a few things from the todo list.

The block can now be configured to open the results in a new window
There is also the option to make it available only to teachers of the course
It now also has a language pack

I also added the ability to choose whether it searches using Google or the search facility in moodle docs.

The attached zip file contains block_searchdocs.php and config_instance.html which need to go in blocks/searchdocs it also contains a lang folder, the file inside this should be placed in your language folder lang/en or whatever.
In reply to Andrew Walker

Re: Search MoodleDocs Block

by Bryan Williams -
Hey Andrew, your modification seems to work as advertised in my 1.6 test installation, nice touch. Can you also change the link for MoodleDocs so a new browser window is opened?
In reply to Bryan Williams

Re: Search MoodleDocs Block

by Andrew Walker -

Hi Bryan,

If you replace the block_searchdocs.php file inside the searchdocs folder with the one attached here it should now make the Moodle Docs link open in a new window.

In reply to Andrew Walker

Re: Search MoodleDocs Block

by Nicole Dunster -

Hi All,

Does this Search MoodleDocs block search all documents within moodle, not just the forums? I'm looking for a searching block to search all documents on a Moodle site that does not use the guest account?

Thanks

Nicole

In reply to Andrew Walker

Re: Search MoodleDocs Block

by Darren Smith -

Ahhh nice work smile

If you change the path of the language file in the zip from lang/block_searchdocs.php to lang/en/searchdocs.php then the langauge file automatically works without moving things around. Also putting it in a blocks folder will mean it will create the correct folder structure when extracted in the moodle root.

See attached (I hope!)

In reply to Andrew Walker

Re: Search MoodleDocs Block

by Matt Gibson -
Hi Andrew,

Good improvements - thanks! I just tried turning on error reporting though and got an error above the block about undefined function: teacheronly

Not sure what this is. Seems to work ok with error reporting off though.

Matt
In reply to Matt Gibson

Re: Search MoodleDocs Block

by Andrew Walker -

Hi Matt,

You're right it doesn't work too well when error reporting is turned up (I should've checked earlier) The attached zip file contains new versions of the files block_searchdocs.php and config_instance.html replace the old versions with these and things should work ok.

Andy

In reply to Jan Dierckx

Re: Search MoodleDocs Block

by Chris Lamb -

At the risk of adding to the confusion by having several different search blocks for MoodleDocs, I've created a simple one, which uses the Moodle search facility and not Google.

The code is basically the FORM code from the search block on the left-hand side of MoodleDocs itself, put inside a simple Block.  It's a standalone file, it uses no language file or database table, and it opens the results in a new browser window.

To install it, create a folder called 'searchmoodledocs' in your 'blocks' folder and copy the attached file into it.  Then go to your Moodle and click the 'Admin' link in your main 'Administration' panel.  That should set it up, and you can then add it from your 'Blocks' dropdown.

As I said, it doesn't use a language file, but there are only three things you need to change for another language.  These are the en in the Form's 'Action' statement, (which define which language section of MoodleDocs it will search) and the text on the two search buttons, which is defined by the button's 'Value' property.

HTH

Chris