Block Columns Dont Show on New Page

Block Columns Dont Show on New Page

от Rachel Dotey -
Number of replies: 3

I have created a new page. It is located inside of a folder in the root of the Moodle directory, so – http://loclahost/moodle/newmodule/index.php. The Block columns do not appear. I’m worried that by putting the new directory in the root of Moodle I may have broken links to the necessary files. I don’t want to turn this into a block because it is supporting several hefty forms that modify a database for majors that I have created. I actually use blocks to display the information and this is really the administrative panel.


Does anyone have any ideas?

<?PHP
require_once('../config.php');
require_once($CFG->libdir.'/weblib.php');
require_once('edit_major_form.php');

print_header_simple('Major', 'heading', 'navigation', '', '', true, '&nbsp;', '', false, '', false);

$_GET['major'] = 'add'; // For testing
if(isset($_GET['major'])) {
switch ($_GET['major']) {
case add:
$heading = 'Add a New Major';
$mform = new add_major_form();
break;
case editmajor:
$heading = 'Select a Major to Edit';
$mform = new choose_edit_major_form('editform');
break;
case edit:
$heading = 'Edit Major';
$mform = new edit_major_form();
echo 'Im in the if statement on index because I have an edit<br/>';
if(isset($_GET['id'])) {
$foundmajor = $mform->fill_edit_form($_GET['id']);
echo 'Im in the if statement on index because I have an id<br/>';
print_r($foundmajor);
$mform->set_data($foundmajor);
//$mform->display();
}
break;
case disable:
$heading = 'Disable a Major';
$mform = new remove_major_form();
break;
default:
$heading = 'Add a New Major';
$mform = new add_major_form();
}
}

echo '<div class="admin">'; // Admin Box For Style Purposes
echo '<h2 class="headingblock header ">'.$heading.'</h2>';
echo '<div class="generalbox">'; // Containing Box

if ($mform->is_cancelled()){
//here you tell php what to do if your user presses cancel
echo 'Canceled'; // Eventually change this to go to a Show All Majors Page
}
// this branch is where you process validated data
else if ($fromform=$mform->get_data()){
print_r($errors);
$mform->display();
}
// else is executed if the form is submitted but the data doesnt validate
// or on the first display of the form.
else {


//"<a href=\"$CFG->wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural</a> ->
//$strnav $streditinga", $mform->focus(), "", false);
//notice use of $mform->focus() above which puts the cursor
//in the first form field or the first field with an error.


//put data you want to fill out in the form into array $toform here then :
// $mform->set_data();
print_r($msform->$errors);
$mform->display();
}

echo '</div>'; // End Containing Box
echo '</div>'; // End Admin Box For Style Purposes
print_footer($course=NULL, $usercourse=NULL, $return=false);

?>
In reply to Rachel Dotey

Re: Block Columns Dont Show on New Page

от sam marshall -
Снимка на Core developers Снимка на Peer reviewers Снимка на Plugin developers
Unfortunately block columns don't show by magic - you have to write code to make them appear. Look at the code for any module that supports blocks to see how to do this.

I seem to recall it's a pain in the backside and requires writing a pagelib.php or something.

(It is different (much easier) in Moodle 2 - which kind of is 'magic' in this case - but this looks like 1.9 code to me.)

--sam
In reply to sam marshall

Re: Block Columns Dont Show on New Page

от Rachel Dotey -
Yes I am working in 1.9 - I didn't think that Moodle 2.0 was really out yet? Is it worth it to switch?

I had looked for code on another page but I didn't see anything that looked to be what I wanted. I will look again and try a few things.

Thank you Sam.

If anyone else could point me to materials on this I would be much appreciative. облещен