Đây là những gì mà tớ nghiên cứu và nghịch ra được, có gì các bạn cho ý kiến trao đổi.
Chúng ta đi từng phần một, trước hết là tạo những block đơn giản nhất.
Để thiết lập một block mới, ví dụ để tạo block giúp đặt nút tìm kiếm của Google lên site Moodle, bạn cần làm một số bước như sau:
1. Tạo thư mục moodle/blocks/googlesearch/
2. Tạo một file có tên : moodle/blocks/blockmoi/block_googlesearch.php
3. Cấu trúc của một file block_....php gồm các phần cơ bản như sau :
<?php
class block_googlesearch extends block_base { // dòng này bạn đã đặt tên của block là : block_googlesearch
function init() { //function nay giup dinh nghia block : ten, version//
$this->title = "Tìm kiếm trên Google"; // title của block//
$this->version = 2008112000; //version của block//
}
function get_content() { //function nhập nội dung vào block//
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass; // dinh nghia noi dung HTML trong blog do//
$this->content->text = '’ // thêm nội dung của block ở đây
$this->content->footer = ''; //footer cua blog, bạn có thể để nội dung gì tuỳ bạn//
return $this->content;
}
}
?>
Qua ví dụ này các bạn có thể tạo ra các block tương ứng cho mình. Ví dụ muốn đặt Google search, bạn chỉ cần thêm script sau (tác giả của script này là bạn Nguyễn Chính Văn) vào $this->content_>text = ‘’
<center>
<form method="get" action="http://www.google.com/custom" target="_top">
<table bgcolor="#ffffff">
<tr><td nowrap="nowrap" valign="top" align="left" height="32">
<p dir="ltr">
<img src="http://www.google.com/logos/Logo_25wht.gif" border="0" alt="Google" align="middle" width="75" height="32"
<a href="http://www.google.com/">
</a><input type="text" name="q" size="12" maxlength="255" value="" id="sbi"></input>
<input type="submit" name="sa" value="Tìm" id="sbb"></input>
<input type="hidden" name="client" value="pub-2065268365108962"></input>
<input type="hidden" name="forid" value="1"></input>
<input type="hidden" name="ie" value="UTF-8"></input>
<input type="hidden" name="oe" value="UTF-8"></input>
<input type="hidden" name="safe" value="active"></input>
<input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1"></input>
<input type="hidden" name="hl" value="vi"></input>
</td></tr></table>
</form>
</center>
chúc các bạn thành công.