title: Using Moodle get_category_formatted_description method in theme lib.php - Moodle 3.11
body: <p>I've got a theme and want to format the frontpage to my design.  I need the course description which I know is stored in the database table course_categories.  However to ensure it renders correctly I need to use the course renderer method - get_category_formatted_description.  The code I'm using doesn't seem to work.</p>
  <p>My (non-OOP) frontpage.php calls  mytheme/lib.php function:</p>
  <pre><code>function theme_getcourses() {
  global $DB;
  $output = &quot;&quot;;
  $table = &quot;course_categories&quot;;
  $params = array('id'=&gt;1);
  $sql = &quot;SELECT * FROM {course_categories} WHERE id &gt; :id ORDER BY idnumber &quot;;
  $categories = $DB-&gt;get_records_sql($sql, $params);
  foreach($categories as $cat) {
      $chelper = new \coursecat_helper();
      $output .= $chelper-&gt;get_category_formatted_description($cat-&gt;id);
  }
  
  return $output;
  </code></pre>
  <p>}</p>
  <p>This doesn't return anything at all, despite being about to get the category description via $cat-&gt;description.  (which doesn't fetch images correctly).</p>
  <p>I hope this makes sense and someone can advise where I'm going wrong.</p>
  <p>Thanks</p>
  <p>Dave</p>