LECTER
LECTER

Reputation: 21

Error in Moodle.... (page in blank)

7 and i want to make some modifications in the header of page.

The modification is get the teacher name of the course and put them in the header when user click in the course.

But the problem is: When i put the next code in the header, the page show in blank, somebody know the reason?

This is my code:

<a class="logo" href="<?php echo preg_replace("(https?:)", "", 
        $CFG->wwwroot); ?>" 
       title="<?php print_string('home'); ?>">
</a>
<div id="course_name">
<?php
    $courseid = $PAGE->course->id;
    if ($courseid==1) {}
    else { 
        $coursename = $PAGE->course->shortname;
        echo $coursename;
    }
?>
</div>
<div id="teacher_name">
<?php 
     if ($course->has_course_contacts()) {
          foreach ($course->get_course_contacts() as $userid => $coursecontact) {
              $name = $coursecontact['rolename'].': '.
                    html_writer::link(new moodle_url('/user/view.php',
                    array('id' => $userid, 'course' => SITEID)),
                    $coursecontact['username']);
              echo $name;
            }
    }
  ?>
  </div>

Upvotes: 2

Views: 1947

Answers (1)

Jonny Vu
Jonny Vu

Reputation: 1428

While developing moodle, you should show all notice and error to clarify how the system going failed.

In the config.php:

@error_reporting(E_ALL | E_STRICT);
@ini_set('display_errors', '1');
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = 1;

With my exp, your $coursecontact included all information about a specific teacher but default, the information about username is blank.

Try to edit config.php with this line:

$CFG->showuseridentity = 'username,email';

It will select username, email field form mdl_user table for all user select requests.

Hope this help.

Upvotes: 2

Related Questions