Archive for the ‘Uncategorized’ Category

Moodle Global Search inside Books

Saturday, September 4th, 2010

In order to inculude Books in the Global Search in Moodle complete the following steps:

add the following lines to /search/lib.php just after the initial Global declerations

define('SEARCH_TYPE_BOOK', 'book');
define('PATH_FOR_SEARCH_TYPE_BOOK', 'mod/book');

Then copy /search/documents/data_document.php and rename to /search/documents/book_document.php

replace all variable names of “data” with “label” (watch out for plurals)

Need to use moodles get_context_instance_by_id function in order to return the correct instance ID so that you can link directly to the resource

add the following line to the __construct function

$context = get_context_instance_by_id($context_id);

and then change the $doc->url line to this:

$doc->url = book_make_link($context->instanceid);

This will return the instance id of the book so that the user can click directly into the book, further work needs to be done in order to return the subchapter of the book so that the user can click directly into the actual page / subchapter within the book to see the results.

To get a full search in all content create a new function like below and use its return to put content into the $doc->contents variable.

function get_book_content($book_id){
	$sql_get_book_contents = "SELECT bc.title, bc.content FROM mdl_book_chapters bc,
				mdl_book b WHERE
				bc.bookid = $book_id AND
				bc.hidden = 0
				ORDER BY bc.bookid, bc.pagenum";

	$book_contents_array = get_records_sql($sql_get_book_contents);

	foreach ($book_contents_array as $book_temp){
		foreach ($book_temp as $book_temp_item){
			$book_full_content .= $book_temp_item;
		}
	}

	return strip_tags($book_full_content);

}

test that your new document class is ok by running /search/tests/index.php

if all ok then rebuild index /search/indexersplash.php then go and put the kettle on as it can take over 10 mins depending on size of your moodle

then run a few tests seeing if any books are returned!

Let me know if this works for you and any tweaks to the code are more than welcome.

too busy to blog

Tuesday, August 24th, 2010

haven’t had a chance to sit down this summer, lots of projects going on.

i’ve been working with EC2, Recurly.com & WordPress integration, SSL third part CAs, theming a Moodle instillation and making a PHP app talk to a MsSql server…

will try to get some more detailed posts up soon!

image extraction from wordpress page

Thursday, June 10th, 2010

i’ve been building a custom wordpress theme for a client and as part of the CMS requirments they wanted to have a slideshow gallery for their projects.

i’ve used the smooth slider plugin which takes the first image in every post added to it and displays it as a gallery, i’ve then called the gallery from the sidebar…

the only problem was that when you were viewing the page relating to a specific gallery item (project) there was no way of controlling what image was shown on the gallery

but i added this nice little bit of code inside “the loop”, which test to see if the content has an image in it and then displays it in the sidebar (rather than the main content) and if it doesnt have an image displays the scrolling gallery.

$first_img = ”;
ob_start();
ob_end_clean();
$output = preg_match_all(‘/<img.+src=[\'"]([^\'"]+)[\'"].*>/i’, $post->post_content, $matches);
$first_img = $matches [1] [0];
$first_img = ”;
ob_start();
ob_end_clean();
$output = preg_match_all(‘/<img.+src=[\'"]([^\'"]+)[\'"].*>/i’, $post->post_content, $matches);
$first_img = $matches [1] [0];

so all images within the_content() are stored in the array and can then be passed to some jquery image rotators.

fedora core 6 upgrade

Tuesday, February 9th, 2010

having an absolute nightmare trying to get php 5.2 upgraded from 5.1.6 on fedora core 6…

think i might just have to take the whole server down and re-image it with ubuntu 8.04 but will have to read up about installing Plesk remotely as not sure if 1and1 will help me with that…

cms/blogging platforms… decisions, decisions…

Tuesday, February 9th, 2010

getting really bored of using wordpress as a cms… don’t get me wrong, I still like it as a blogging platform and as a quick fix solution for throwing websites up very quickly, but think i need something else to get my teeth into.

i’ve been putting a few test sites together with drupal, and i think its quite good… i must admit i’ve been scared to get into it, but now i’m paddling in the shallow end it doesn’t seem as scary as i thought it was… i wouldn’t use it for just a blogging site though… its got so much more to it… but i am in the process of developing a site for the Scottish Soulful Weekender and am going to jump in with drupal on that site… wish me luck

visited aleks krotoski’s blog page after watching her bbc2 docu and saw she is using a ruby based blog platform called thoth, which looks quite nice… and very fast, but don’t know that much about ruby so wondering if i should investigate more?

wordpress event calender plugin

Tuesday, December 15th, 2009

I’m currently developing a new site for aoklearning and have chosen to use wordpress… (I know, I know, it will be restricting but my thinking behind it is to make it so easy to use that the directors and other staff will be able to update it themselves without having to ask me everytime a new course or new project is created…)

Found this plugin… http://www.wp-eventscalendar.com/ and I am currently in the process of adding some extra fields to the administration side of it, like price, canceled, fully booked, etc…  Once I’m happy with how it works I’ll put up some code snippets here… stay tuned…

yahoo bots

Wednesday, December 2nd, 2009

A server that I am helping with, hosted by UKWSD has been subject to a heavy load recently…

They inform us that it was caused by a Yahoo bot constantly crawling the site and causing the overload. You would think a company such as Yahoo would have a more graceful bot routine? Will investigate more…

cakephp

Monday, November 23rd, 2009

Been using CakePhp for a new project… really good so far, will probably make another post on it when I’ve figured it out a bit more.

google is you friend

Thursday, October 8th, 2009

A smallish site I look after recently had a database corruption, which resulted in all the wordpress pages and posts being wiped as I had to re-install wordpress. Fortunately I could recover the html files, themes, etc… and thought that I would have to trawl through all my old emails with the client to rebuild the content… I thought wrong…

A quick google using the “site:www.example.com” showed all of the pages from the site, then clicking the “Cached” link in google showed the entire page as it was a month ago! Excellent! Google saved me a lot of time, but I’ll be putting a more robust backup strategy in place!

google wave invites

Wednesday, September 30th, 2009

Supposedly google wave beta users can now send out invitations… If so I better start dishing them out!

[update]…  got it!  ithinkitsnice.com was the first to ask for one, so have 7 more left…