Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

View all courses: Difference between revisions

From MoodleDocs
(Replaced content with "See Courses and Categories Lists Overview in 2.4 for the current screens")
No edit summary
Line 1: Line 1:
See [[Courses and Categories Lists Overview in 2.4]] for the current screens
See [[Courses and Categories Lists Overview in 2.4]] for the current screens
Basic idea:
Renderer has a base function, i.e. ''courses_and_subcategories_list()'' that accepts a number of options.
Each interface - frontpage, /course/index.php, /course/category.php, etc. has it's own function that themes can override than creates an array of options to be passed to the base function
There is also a script called from AJAX to load extended course contents, category, or another page of list of courses/categories
<pre>
class core_course_renderer {
/** basic function that displays tree of subcategories and list of courses */
public function courses_and_subcategories_list($displayoptions) {
  // ...
}
/** invoked from /index.php */
public function frontpage_course_list($displaytype) {
  if ($displaytype === 'categories' || $displaytype === 'combo') {
    $displayoptions = array(
      'categoryid' => 0,
      'displaysubcategories' => true,
      'expandsubcategories' => $CFG->maxcategorydepth,
      'displaycourses' => ($CFG->frontpage === 'combo') ? 'collapsed' : 'none',
    );
    return $this->courses_and_subcategories_list(0, $displayoptions);
  }
  return '';
}
/** invoked from /course/index.php */
public function courses_list_all() {
  $displayoptions = array(
    'categoryid' => 0,
    'displaysubcategories' => true,
    'displaycourses' => 'collapsed',
  );
  return $this->courses_and_subcategories_list(0, $displayoptions);
}
/** invoked from /course/category.php */
public function course_category($category) {
  $displayoptions = array(
    'categoryid' => 0,
    'displaysubcategories' => true,
    'displaycourses' => 'expanded',
    'coursesperpage' => $CFG->coursesperpage,
    'sortcourses' => 'fullname',
    'sortcategories' => 'fullname',
  );
  return $this->courses_and_subcategories_list($category, $displayoptions);
}
}
</pre>

Revision as of 04:18, 20 December 2012

See Courses and Categories Lists Overview in 2.4 for the current screens

Basic idea:

Renderer has a base function, i.e. courses_and_subcategories_list() that accepts a number of options. Each interface - frontpage, /course/index.php, /course/category.php, etc. has it's own function that themes can override than creates an array of options to be passed to the base function

There is also a script called from AJAX to load extended course contents, category, or another page of list of courses/categories

class core_course_renderer {

/** basic function that displays tree of subcategories and list of courses */
public function courses_and_subcategories_list($displayoptions) {
  // ...
}

/** invoked from /index.php */
public function frontpage_course_list($displaytype) {
  if ($displaytype === 'categories' || $displaytype === 'combo') {
    $displayoptions = array(
      'categoryid' => 0,
      'displaysubcategories' => true,
      'expandsubcategories' => $CFG->maxcategorydepth,
      'displaycourses' => ($CFG->frontpage === 'combo') ? 'collapsed' : 'none',
    );
    return $this->courses_and_subcategories_list(0, $displayoptions);
  }
  return '';
}

/** invoked from /course/index.php */
public function courses_list_all() {
  $displayoptions = array(
    'categoryid' => 0,
    'displaysubcategories' => true,
    'displaycourses' => 'collapsed',
  );
  return $this->courses_and_subcategories_list(0, $displayoptions);
}

/** invoked from /course/category.php */
public function course_category($category) {
  $displayoptions = array(
    'categoryid' => 0,
    'displaysubcategories' => true,
    'displaycourses' => 'expanded',
    'coursesperpage' => $CFG->coursesperpage,
    'sortcourses' => 'fullname',
    'sortcategories' => 'fullname',
  );
  return $this->courses_and_subcategories_list($category, $displayoptions);
}

}