在 Moodle 1.9.2 中塞進自訂的內容

edited 十月 2013 in 數位學習平台
簡單的說就只是披著 Moodle 的皮招搖撞騙 ;)

在根目錄放入 test.php ,裏面有下面程式碼:
<?php
require('config.php');  
require_once($CFG->dirroot .'/course/lib.php');
require_once($CFG->dirroot .'/lib/blocklib.php');

define('BLOCK_L_MIN_WIDTH', 160);
define('BLOCK_L_MAX_WIDTH', 210);
define('BLOCK_R_MIN_WIDTH', 160);
define('BLOCK_R_MAX_WIDTH', 210);

$PAGE       = page_create_object(PAGE_COURSE_VIEW, SITEID);
$pageblocks = blocks_setup($PAGE);
$editing    = $PAGE->user_is_editing();
$preferred_width_left  = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),  
                                        BLOCK_L_MAX_WIDTH);
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 
                                        BLOCK_R_MAX_WIDTH);

print_header(strip_tags($SITE->fullname), $SITE->fullname, 'home', '',
'<meta name="description" content="'. s(strip_tags($SITE->summary)) .'" />',
true, '', user_login_string($SITE).$langmenu);
?> 
<table id="layout-table">
  <tr>
  <?php
    if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
        echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
        echo '</td>';
    }

    echo '<td id="middle-column">';
//自訂內容開始

echo 'hello world!';

//自訂內容結束
    echo '</td>';


    if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing || isadmin()) {
        echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
        if (isadmin()) {
            echo '<div align="center">'.update_course_icon($SITE->id).'</div>';
            echo '<br />';
        }
        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
        echo '</td>';
    }

?>
  </tr>
</table>
<?php
print_footer('home');
把需要顯示的內容放入自訂內容標示的位置即可。

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=4035
Sign In or Register to comment.