Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

Classes for rendering HTML output for Moodle. Please see {@link http://docs.moodle.org/en/Developement:How_Moodle_outputs_HTML} for an overview.

Copyright: 2009 Tim Hunt
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 5632 lines (223 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 6 classes

renderer_base:: (13 methods):
  get_mustache()
  __construct()
  render_from_template()
  render()
  add_action_handler()
  has_started()
  prepare_classes()
  pix_url()
  image_url()
  get_logo_url()
  get_compact_logo_url()
  should_display_navbar_logo()
  should_display_main_logo()

plugin_renderer_base:: (3 methods):
  __construct()
  render()
  __call()

core_renderer:: (156 methods):
  __construct()
  doctype()
  htmlattributes()
  standard_head_html()
  standard_top_of_body_html()
  maintenance_warning()
  standard_footer_html()
  debug_footer_html()
  main_content()
  activity_information()
  activity_navigation()
  standard_end_of_body_html()
  standard_after_main_region_html()
  login_info()
  is_login_page()
  home_link()
  redirect_message()
  header()
  render_page_layout()
  footer()
  container_end_all()
  course_content_header()
  course_content_footer()
  course_header()
  course_footer()
  get_generated_image_for_id()
  get_generated_color_for_id()
  lang_menu()
  block_controls()
  print_textarea()
  render_action_menu()
  render_check_result()
  check_result()
  render_action_menu_link()
  render_action_menu_filler()
  render_action_menu_link_primary()
  render_action_menu_link_secondary()
  block()
  list_block_contents()
  blocks_for_region()
  block_move_target()
  action_link()
  render_action_link()
  action_icon()
  confirm()
  single_button()
  render_single_button()
  single_select()
  download_dataformat_selector()
  render_single_select()
  url_select()
  render_url_select()
  doc_link()
  image_icon()
  render_image_icon()
  pix_icon()
  render_pix_icon()
  render_pix_emoticon()
  render_rating()
  heading_with_help()
  old_help_icon()
  help_icon()
  render_help_icon()
  help_icon_scale()
  spacer()
  user_picture()
  render_user_picture()
  htmllize_file_tree()
  file_picker()
  render_file_picker()
  update_module_button()
  edit_button()
  edit_switch()
  close_window_button()
  error_text()
  fatal_error()
  notification()
  notify_problem()
  notify_success()
  notify_message()
  notify_redirect()
  render_notification()
  continue_button()
  paging_bar()
  render_paging_bar()
  initials_bar()
  render_initials_bar()
  skip_link_target()
  heading()
  box()
  box_start()
  box_end()
  container()
  container_start()
  container_end()
  tree_block_contents()
  search_box()
  navbar_plugin_output()
  user_menu()
  secure_layout_login_info()
  secure_layout_language_menu()
  navbar()
  render_breadcrumb_navigation_node()
  render_navigation_node()
  rarrow()
  larrow()
  uarrow()
  darrow()
  custom_menu()
  custom_menu_flat()
  render_custom_menu()
  render_custom_menu_item()
  theme_switch_links()
  tabtree()
  render_tabtree()
  render_tabobject()
  blocks()
  custom_block_region()
  body_css_classes()
  body_id()
  body_attributes()
  page_heading()
  page_heading_button()
  page_doc_link()
  supportemail()
  services_support_link()
  has_popover_links()
  page_heading_menu()
  page_title()
  favicon()
  render_preferences_groups()
  render_preferences_group()
  context_header()
  render_skip_links()
  render_context_header()
  full_header()
  context_header_settings_menu()
  build_action_menu_from_navigation()
  region_main_settings_menu()
  tag_list()
  render_inplace_editable()
  render_chart_bar()
  render_chart_line()
  render_chart_pie()
  render_chart()
  render_login()
  mform_element()
  render_login_signup_form()
  render_verify_age_location_page()
  render_digital_minor_page()
  render_progress_bar()
  render_progress_bar_update()
  render_checkbox_toggleall()
  render_participants_tertiary_nav()
  moodle_release()
  addblockbutton()

core_renderer_cli:: (10 methods):
  header()
  render_check_result()
  check_result()
  render_progress_bar()
  render_progress_bar_update()
  heading()
  fatal_error()
  notification()
  footer()
  render_notification()

core_renderer_ajax:: (6 methods):
  fatal_error()
  notification()
  redirect_message()
  header()
  footer()
  heading()

core_renderer_maintenance:: (17 methods):
  __construct()
  block()
  blocks()
  blocks_for_region()
  course_content_header()
  course_content_footer()
  course_header()
  course_footer()
  custom_menu()
  file_picker()
  htmllize_file_tree()
  confirm()
  init_block_hider_js()
  lang_menu()
  login_info()
  secure_login_info()
  user_picture()


Class: renderer_base  - X-Ref

Simple base class for Moodle renderers.

Tracks the xhtml_container_stack to use, which is passed in in the constructor.

Also has methods to facilitate generating HTML output.

get_mustache()   X-Ref
Return an instance of the mustache class.

return: Mustache_Engine

__construct(moodle_page $page, $target)   X-Ref
Constructor

The constructor takes two arguments. The first is the page that the renderer
has been created to assist with, and the second is the target.
The target is an additional identifier that can be used to load different
renderers for different options.

param: moodle_page $page the page we are doing output for.
param: string $target one of rendering target constants

render_from_template($templatename, $context)   X-Ref
Renders a template by name with the given context.

The provided data needs to be array/stdClass made up of only simple types.
Simple types are array,stdClass,bool,int,float,string

return: string|boolean
param: array|stdClass $context Context containing data for the template.

render(renderable $widget)   X-Ref
Returns rendered widget.

The provided widget needs to be an object that extends the renderable
interface.
If will then be rendered by a method based upon the classname for the widget.
For instance a widget of class `crazywidget` will be rendered by a protected
render_crazywidget method of this renderer.
If no render_crazywidget method exists and crazywidget implements templatable,
look for the 'crazywidget' template in the same component and render that.

return: string
param: renderable $widget instance with renderable interface

add_action_handler(component_action $action, $id = null)   X-Ref
Adds a JS action for the element with the provided id.

This method adds a JS event for the provided component action to the page
and then returns the id that the event has been attached to.
If no id has been provided then a new ID is generated by {@link html_writer::random_id()}

return: string id of element, either original submitted or random new if not supplied
param: component_action $action
param: string $id

has_started()   X-Ref
Returns true is output has already started, and false if not.

return: boolean true if the header has been printed.

prepare_classes($classes)   X-Ref
Given an array or space-separated list of classes, prepares and returns the HTML class attribute value

return: string HTML class attribute value
param: mixed $classes Space-separated string or array of classes

pix_url($imagename, $component = 'moodle')   X-Ref
Return the direct URL for an image from the pix folder.

Use this function sparingly and never for icons. For icons use pix_icon or the pix helper in a mustache template.

return: moodle_url
param: string $imagename the name of the icon.
param: string $component specification of one plugin like in get_string()

image_url($imagename, $component = 'moodle')   X-Ref
Return the moodle_url for an image.

The exact image location and extension is determined
automatically by searching for gif|png|jpg|jpeg, please
note there can not be diferent images with the different
extension. The imagename is for historical reasons
a relative path name, it may be changed later for core
images. It is recommended to not use subdirectories
in plugin and theme pix directories.

There are three types of images:
1/ theme images  - stored in theme/mytheme/pix/,
use component 'theme'
2/ core images   - stored in /pix/,
overridden via theme/mytheme/pix_core/
3/ plugin images - stored in mod/mymodule/pix,
overridden via theme/mytheme/pix_plugins/mod/mymodule/,
example: image_url('comment', 'mod_glossary')

return: moodle_url
param: string $imagename the pathname of the image
param: string $component full plugin name (aka component) or 'theme'

get_logo_url($maxwidth = null, $maxheight = 200)   X-Ref
Return the site's logo URL, if any.

return: moodle_url|false
param: int $maxwidth The maximum width, or null when the maximum width does not matter.
param: int $maxheight The maximum height, or null when the maximum height does not matter.

get_compact_logo_url($maxwidth = 300, $maxheight = 300)   X-Ref
Return the site's compact logo URL, if any.

return: moodle_url|false
param: int $maxwidth The maximum width, or null when the maximum width does not matter.
param: int $maxheight The maximum height, or null when the maximum height does not matter.

should_display_navbar_logo()   X-Ref
Whether we should display the logo in the navbar.

We will when there are no main logos, and we have compact logo.

return: bool

should_display_main_logo($headinglevel = 1)   X-Ref
Whether we should display the main logo.

return: bool
param: int $headinglevel The heading level we want to check against.

Class: plugin_renderer_base  - X-Ref

Basis for all plugin renderers.

__construct(moodle_page $page, $target)   X-Ref
Constructor method, calls the parent constructor

param: moodle_page $page
param: string $target one of rendering target constants

render(renderable $widget)   X-Ref
Renders the provided widget and returns the HTML to display it.

return: string
param: renderable $widget instance with renderable interface

__call($method, $arguments)   X-Ref
Magic method used to pass calls otherwise meant for the standard renderer
to it to ensure we don't go causing unnecessary grief.

return: mixed
param: string $method
param: array $arguments

Class: core_renderer  - X-Ref

The standard implementation of the core_renderer interface.

__construct(moodle_page $page, $target)   X-Ref
Constructor

param: moodle_page $page the page we are doing output for.
param: string $target one of rendering target constants

doctype()   X-Ref
Get the DOCTYPE declaration that should be used with this page. Designed to
be called in theme layout.php files.

return: string the DOCTYPE declaration that should be used.

htmlattributes()   X-Ref
The attributes that should be added to the <html> tag. Designed to
be called in theme layout.php files.

return: string HTML fragment.

standard_head_html()   X-Ref
The standard tags (meta tags, links to stylesheets and JavaScript, etc.)
that should be included in the <head> tag. Designed to be called in theme
layout.php files.

return: string HTML fragment.

standard_top_of_body_html()   X-Ref
The standard tags (typically skip links) that should be output just inside
the start of the <body> tag. Designed to be called in theme layout.php files.

return: string HTML fragment.

maintenance_warning()   X-Ref
Scheduled maintenance warning message.

Note: This is a nasty hack to display maintenance notice, this should be moved
to some general notification area once we have it.

return: string

standard_footer_html()   X-Ref
content that should be output in the footer area
of the page. Designed to be called in theme layout.php files.

return: string HTML fragment.

debug_footer_html()   X-Ref
Performance information and validation links for debugging.

return: string HTML fragment.

main_content()   X-Ref
Returns standard main content placeholder.
Designed to be called in theme layout.php files.

return: string HTML fragment.

activity_information(cm_info $cminfo, cm_completion_details $completiondetails, array $activitydates)   X-Ref
Returns information about an activity.

return: string the activity information HTML.
param: cm_info $cminfo The course module information.
param: cm_completion_details $completiondetails The completion details for this activity module.
param: array $activitydates The dates for this activity module.

activity_navigation()   X-Ref
Returns standard navigation between activities in a course.

return: string the navigation HTML.

standard_end_of_body_html()   X-Ref
The standard tags (typically script tags that are not needed earlier) that
should be output after everything else. Designed to be called in theme layout.php files.

return: string HTML fragment.

standard_after_main_region_html()   X-Ref
The standard HTML that should be output just before the <footer> tag.
Designed to be called in theme layout.php files.

return: string HTML fragment.

login_info($withlinks = null)   X-Ref
Return the standard string that says whether you are logged in (and switched
roles/logged in as another user).

return: string HTML fragment.
param: bool $withlinks if false, then don't include any links in the HTML produced.

is_login_page()   X-Ref
Check whether the current page is a login page.

return: bool

home_link()   X-Ref
Return the 'back' link that normally appears in the footer.

return: string HTML fragment.

redirect_message($encodedurl, $message, $delay, $debugdisableredirect,$messagetype = \core\output\notification::NOTIFY_INFO)   X-Ref
Redirects the user by any means possible given the current state

This function should not be called directly, it should always be called using
the redirect function in lib/weblib.php

The redirect function should really only be called before page output has started
however it will allow itself to be called during the state STATE_IN_BODY

return: string The HTML to display to the user before dying, may contain
param: string $encodedurl The URL to send to encoded if required
param: string $message The message to display to the user if any
param: int $delay The delay before redirecting a user, if $message has been
param: boolean $debugdisableredirect this redirect has been disabled for
param: string $messagetype The type of notification to show the message in.

header()   X-Ref
Start output by sending the HTTP headers, and printing the HTML <head>
and the start of the <body>.

To control what is printed, you should set properties on $PAGE.

return: string HTML that you must output this, preferably immediately.

render_page_layout($layoutfile)   X-Ref
Renders and outputs the page layout file.

This is done by preparing the normal globals available to a script, and
then including the layout file provided by the current theme for the
requested layout.

return: string HTML code
param: string $layoutfile The name of the layout file

footer()   X-Ref
Outputs the page's footer

return: string HTML fragment

container_end_all($shouldbenone = false)   X-Ref
Close all but the last open container. This is useful in places like error
handling, where you want to close all the open containers (apart from <body>)
before outputting the error message.

return: string the HTML required to close any open containers inside <body>.
param: bool $shouldbenone assert that the stack should be empty now - causes a

course_content_header($onlyifnotcalledbefore = false)   X-Ref
Returns course-specific information to be output immediately above content on any course page
(for the current course)

return: string
param: bool $onlyifnotcalledbefore output content only if it has not been output before

course_content_footer($onlyifnotcalledbefore = false)   X-Ref
Returns course-specific information to be output immediately below content on any course page
(for the current course)

return: string
param: bool $onlyifnotcalledbefore output content only if it has not been output before

course_header()   X-Ref
Returns course-specific information to be output on any course page in the header area
(for the current course)

return: string

course_footer()   X-Ref
Returns course-specific information to be output on any course page in the footer area
(for the current course)

return: string

get_generated_image_for_id($id)   X-Ref
Get the course pattern datauri to show on a course card.

The datauri is an encoded svg that can be passed as a url.
return: string datauri
param: int $id Id to use when generating the pattern

get_generated_color_for_id($id)   X-Ref
Get the course color to show on a course card.

return: string hex color code.
param: int $id Id to use when generating the color.

lang_menu()   X-Ref
Returns lang menu or '', this method also checks forcing of languages in courses.

This function calls {@link core_renderer::render_single_select()} to actually display the language menu.

return: string The lang menu HTML or empty string

block_controls($actions, $blockid = null)   X-Ref
Output the row of editing icons for a block, as defined by the controls array.

return: string HTML fragment.
param: array $controls an array like {@link block_contents::$controls}.
param: string $blockid The ID given to the block.

print_textarea($name, $id, $value, $rows, $cols)   X-Ref
Returns the HTML for a basic textarea field.

return: string the HTML to display
param: string $name Name to use for the textarea element
param: string $id The id to use fort he textarea element
param: string $value Initial content to display in the textarea
param: int $rows Number of rows to display
param: int $cols Number of columns to display

render_action_menu(action_menu $menu)   X-Ref
Renders an action menu component.

return: string HTML
param: action_menu $menu

render_check_result(core\check\result $result)   X-Ref
Renders a Check API result

return: string HTML fragment
param: result $result

check_result(core\check\result $result)   X-Ref
Renders a Check API result

return: string HTML fragment
param: result $result

render_action_menu_link(action_menu_link $action)   X-Ref
Renders an action_menu_link item.

return: string HTML fragment
param: action_menu_link $action

render_action_menu_filler(action_menu_filler $action)   X-Ref
Renders a primary action_menu_filler item.

return: string HTML fragment
param: action_menu_link_filler $action

render_action_menu_link_primary(action_menu_link_primary $action)   X-Ref
Renders a primary action_menu_link item.

return: string HTML fragment
param: action_menu_link_primary $action

render_action_menu_link_secondary(action_menu_link_secondary $action)   X-Ref
Renders a secondary action_menu_link item.

return: string HTML fragment
param: action_menu_link_secondary $action

block(block_contents $bc, $region)   X-Ref
Prints a nice side block with an optional header.

return: string the HTML to be output.
param: block_contents $bc HTML for the content
param: string $region the region the block is appearing in.

list_block_contents($icons, $items)   X-Ref
Render the contents of a block_list.

return: string HTML
param: array $icons the icon for each item.
param: array $items the content of each item.

blocks_for_region($region, $fakeblocksonly = false)   X-Ref
Output all the blocks in a particular region.

return: string the HTML to be output.
param: string $region the name of a region on this page.
param: boolean $fakeblocksonly Output fake block only.

block_move_target($target, $zones, $previous, $region)   X-Ref
Output a place where the block that is currently being moved can be dropped.

return: string the HTML to be output.
param: block_move_target $target with the necessary details.
param: array $zones array of areas where the block can be moved to
param: string $previous the block located before the area currently being rendered.
param: string $region the name of the region

action_link($url, $text, component_action $action = null, array $attributes = null, $icon = null)   X-Ref
Renders a special html link with attached action

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_action_link()} instead.

return: string HTML fragment
param: string|moodle_url $url
param: string $text HTML fragment
param: component_action $action
param: array $attributes associative array of html link attributes + disabled
param: pix_icon optional pix icon to render with the link

render_action_link(action_link $link)   X-Ref
Renders an action_link object.

The provided link is renderer and the HTML returned. At the same time the
associated actions are setup in JS by {@link core_renderer::add_action_handler()}

return: string HTML fragment
param: action_link $link

action_icon($url, pix_icon $pixicon, component_action $action = null, array $attributes = null, $linktext=false)   X-Ref
Renders an action_icon.

This function uses the {@link core_renderer::action_link()} method for the
most part. What it does different is prepare the icon as HTML and use it
as the link text.

Theme developers: If you want to change how action links and/or icons are rendered,
consider overriding function {@link core_renderer::render_action_link()} and
{@link core_renderer::render_pix_icon()}.

return: string HTML fragment
param: string|moodle_url $url A string URL or moodel_url
param: pix_icon $pixicon
param: component_action $action
param: array $attributes associative array of html link attributes + disabled
param: bool $linktext show title next to image in link

confirm($message, $continue, $cancel, array $displayoptions = [])   X-Ref
Print a message along with button choices for Continue/Cancel

If a string or moodle_url is given instead of a single_button, method defaults to post.

return: string HTML fragment
param: string $message The question to ask the user
param: single_button|moodle_url|string $continue The single_button component representing the Continue answer. Can also be a moodle_url or string URL
param: single_button|moodle_url|string $cancel The single_button component representing the Cancel answer. Can also be a moodle_url or string URL
param: array $displayoptions optional extra display options

single_button($url, $label, $method='post', array $options=null)   X-Ref
Returns a form with a single button.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_single_button()} instead.

return: string HTML fragment
param: string|moodle_url $url
param: string $label button text
param: string $method get or post submit method
param: array $options associative array {disabled, title, etc.}

render_single_button(single_button $button)   X-Ref
Renders a single button widget.

This will return HTML to display a form containing a single button.

return: string HTML fragment
param: single_button $button

single_select($url, $name, array $options, $selected = '',$nothing = array('' => 'choosedots')   X-Ref
Returns a form with a single select widget.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_single_select()} instead.

return: string HTML fragment
param: moodle_url $url form action target, includes hidden fields
param: string $name name of selection field - the changing parameter in url
param: array $options list of options
param: string $selected selected element
param: array $nothing
param: string $formid
param: array $attributes other attributes for the single select

download_dataformat_selector($label, $base, $name = 'dataformat', $params = array()   X-Ref
Returns a dataformat selection and download form

return: string HTML fragment
param: string $label A text label
param: moodle_url|string $base The download page url
param: string $name The query param which will hold the type of the download
param: array $params Extra params sent to the download page

render_single_select(single_select $select)   X-Ref
Internal implementation of single_select rendering

return: string HTML fragment
param: single_select $select

url_select(array $urls, $selected, $nothing = array('' => 'choosedots')   X-Ref
Returns a form with a url select widget.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_url_select()} instead.

return: string HTML fragment
param: array $urls list of urls - array('/course/view.php?id=1'=>'Frontpage', ....)
param: string $selected selected element
param: array $nothing
param: string $formid

render_url_select(url_select $select)   X-Ref
Internal implementation of url_select rendering

return: string HTML fragment
param: url_select $select

doc_link($path, $text = '', $forcepopup = false, array $attributes = [])   X-Ref
Returns a string containing a link to the user documentation.
Also contains an icon by default. Shown to teachers and admin only.

return: string
param: string $path The page link after doc root and language, no leading slash.
param: string $text The text to be displayed for the link
param: boolean $forcepopup Whether to force a popup regardless of the value of $CFG->doctonewwindow
param: array $attributes htm attributes

image_icon($pix, $alt, $component='moodle', array $attributes = null)   X-Ref
Return HTML for an image_icon.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_image_icon()} instead.

return: string HTML fragment
param: string $pix short pix name
param: string $alt mandatory alt attribute
param: string $component standard compoennt name like 'moodle', 'mod_forum', etc.
param: array $attributes htm attributes

render_image_icon(image_icon $icon)   X-Ref
Renders a pix_icon widget and returns the HTML to display it.

return: string HTML fragment
param: image_icon $icon

pix_icon($pix, $alt, $component='moodle', array $attributes = null)   X-Ref
Return HTML for a pix_icon.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_pix_icon()} instead.

return: string HTML fragment
param: string $pix short pix name
param: string $alt mandatory alt attribute
param: string $component standard compoennt name like 'moodle', 'mod_forum', etc.
param: array $attributes htm lattributes

render_pix_icon(pix_icon $icon)   X-Ref
Renders a pix_icon widget and returns the HTML to display it.

return: string HTML fragment
param: pix_icon $icon

render_pix_emoticon(pix_emoticon $emoticon)   X-Ref
Return HTML to display an emoticon icon.

return: string HTML fragment
param: pix_emoticon $emoticon

render_rating(rating $rating)   X-Ref
Produces the html that represents this rating in the UI

return: string
param: rating $rating the page object on which this rating will appear

heading_with_help($text, $helpidentifier, $component = 'moodle', $icon = '', $iconalt = '', $level = 2, $classnames = null)   X-Ref
Centered heading with attached help button (same title text)
and optional icon attached.

return: string HTML fragment
param: string $text A heading text
param: string $helpidentifier The keyword that defines a help page
param: string $component component name
param: string|moodle_url $icon
param: string $iconalt icon alt text
param: int $level The level of importance of the heading. Defaulting to 2
param: string $classnames A space-separated list of CSS classes. Defaulting to null

old_help_icon($helpidentifier, $title, $component = 'moodle', $linktext = '')   X-Ref
Returns HTML to display a help icon.


help_icon($identifier, $component = 'moodle', $linktext = '')   X-Ref
Returns HTML to display a help icon.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_help_icon()} instead.

return: string HTML fragment
param: string $identifier The keyword that defines a help page
param: string $component component name
param: string|bool $linktext true means use $title as link text, string means link text value

render_help_icon(help_icon $helpicon)   X-Ref
Implementation of user image rendering.

return: string HTML fragment
param: help_icon $helpicon A help icon instance

help_icon_scale($courseid, stdClass $scale)   X-Ref
Returns HTML to display a scale help icon.

return: string HTML fragment
param: int $courseid
param: stdClass $scale instance

spacer(array $attributes = null, $br = false)   X-Ref
Creates and returns a spacer image with optional line break.

return: string HTML fragment
param: array $attributes Any HTML attributes to add to the spaced.
param: bool $br Include a BR after the spacer.... DON'T USE THIS. Don't be

user_picture(stdClass $user, array $options = null)   X-Ref
Returns HTML to display the specified user's avatar.

User avatar may be obtained in two ways:
<pre>
// Option 1: (shortcut for simple cases, preferred way)
// $user has come from the DB and has fields id, picture, imagealt, firstname and lastname
$OUTPUT->user_picture($user, array('popup'=>true));

// Option 2:
$userpic = new user_picture($user);
// Set properties of $userpic
$userpic->popup = true;
$OUTPUT->render($userpic);
</pre>

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_user_picture()} instead.

return: string HTML fragment
param: stdClass $user Object with at least fields id, picture, imagealt, firstname, lastname
param: array $options associative array with user picture options, used only if not a user_picture object,

render_user_picture(user_picture $userpicture)   X-Ref
Internal implementation of user image rendering.

return: string
param: user_picture $userpicture

htmllize_file_tree($dir)   X-Ref
Internal implementation of file tree viewer items rendering.

return: string
param: array $dir

file_picker($options)   X-Ref
Returns HTML to display the file picker

<pre>
$OUTPUT->file_picker($options);
</pre>

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_file_picker()} instead.

return: string HTML fragment
param: array $options associative array with file manager options

render_file_picker(file_picker $fp)   X-Ref
Internal implementation of file picker rendering.

return: string
param: file_picker $fp

update_module_button()   X-Ref


edit_button(moodle_url $url, string $method = 'post')   X-Ref
Returns HTML to display a "Turn editing on/off" button in a form.

return: string HTML the button
param: moodle_url $url The URL + params to send through when clicking the button
param: string $method

edit_switch()   X-Ref
Create a navbar switch for toggling editing mode.

return: string Html containing the edit switch

close_window_button($text='')   X-Ref
Returns HTML to display a simple button to close a window

return: string html fragment
param: string $text The lang string for the button's label (already output from get_string())

error_text($message)   X-Ref
Output an error message. By default wraps the error message in <span class="error">.
If the error message is blank, nothing is output.

return: string the HTML to output.
param: string $message the error message.

fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = "")   X-Ref
Do not call this function directly.

To terminate the current script with a fatal error, call the {@link print_error}
function, or throw an exception. Doing either of those things will then call this
function to display the error, before terminating the execution.

return: string the HTML to output.
param: string $message The message to output
param: string $moreinfourl URL where more info can be found about the error
param: string $link Link for the Continue button
param: array $backtrace The execution backtrace
param: string $debuginfo Debugging information

notification($message, $type = null, $closebutton = true)   X-Ref
Output a notification (that is, a status message about something that has just happened).

Note: \core\notification::add() may be more suitable for your usage.

return: string the HTML to output.
param: string $message The message to print out.
param: ?string $type   The type of notification. See constants on \core\output\notification.
param: bool $closebutton Whether to show a close icon to remove the notification (default true).

notify_problem()   X-Ref


notify_success()   X-Ref


notify_message()   X-Ref


notify_redirect()   X-Ref


render_notification(\core\output\notification $notification)   X-Ref
Render a notification (that is, a status message about something that has
just happened).

return: string the HTML to output.
param: \core\output\notification $notification the notification to print out

continue_button($url)   X-Ref
Returns HTML to display a continue button that goes to a particular URL.

return: string the HTML to output.
param: string|moodle_url $url The url the button goes to.

paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar = 'page')   X-Ref
Returns HTML to display a single paging bar to provide access to other pages  (usually in a search)

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_paging_bar()} instead.

return: string the HTML to output.
param: int $totalcount The total number of entries available to be paged through
param: int $page The page you are currently viewing
param: int $perpage The number of entries that should be shown per page
param: string|moodle_url $baseurl url of the current page, the $pagevar parameter is added
param: string $pagevar name of page parameter that holds the page number

render_paging_bar(paging_bar $pagingbar)   X-Ref
Returns HTML to display the paging bar.

return: string the HTML to output.
param: paging_bar $pagingbar

initials_bar($current, $class, $title, $urlvar, $url, $alpha = null)   X-Ref
Returns HTML to display initials bar to provide access to other pages  (usually in a search)

return: string the HTML to output.
param: string $current the currently selected letter.
param: string $class class name to add to this initial bar.
param: string $title the name to put in front of this initial bar.
param: string $urlvar URL parameter name for this initial.
param: string $url URL object.
param: array $alpha of letters in the alphabet.

render_initials_bar(initials_bar $initialsbar)   X-Ref
Internal implementation of initials bar rendering.

return: string
param: initials_bar $initialsbar

skip_link_target($id = null)   X-Ref
Output the place a skip link goes to.

return: string the HTML to output.
param: string $id The target name from the corresponding $PAGE->requires->skip_link_to($target) call.

heading($text, $level = 2, $classes = null, $id = null)   X-Ref
Outputs a heading

return: string the HTML to output.
param: string $text The text of the heading
param: int $level The level of importance of the heading. Defaulting to 2
param: string $classes A space-separated list of CSS classes. Defaulting to null
param: string $id An optional ID

box($contents, $classes = 'generalbox', $id = null, $attributes = array()   X-Ref
Outputs a box.

return: string the HTML to output.
param: string $contents The contents of the box
param: string $classes A space-separated list of CSS classes
param: string $id An optional ID
param: array $attributes An array of other attributes to give the box.

box_start($classes = 'generalbox', $id = null, $attributes = array()   X-Ref
Outputs the opening section of a box.

return: string the HTML to output.
param: string $classes A space-separated list of CSS classes
param: string $id An optional ID
param: array $attributes An array of other attributes to give the box.

box_end()   X-Ref
Outputs the closing section of a box.

return: string the HTML to output.

container($contents, $classes = null, $id = null)   X-Ref
Outputs a container.

return: string the HTML to output.
param: string $contents The contents of the box
param: string $classes A space-separated list of CSS classes
param: string $id An optional ID

container_start($classes = null, $id = null)   X-Ref
Outputs the opening section of a container.

return: string the HTML to output.
param: string $classes A space-separated list of CSS classes
param: string $id An optional ID

container_end()   X-Ref
Outputs the closing section of a container.

return: string the HTML to output.

tree_block_contents($items, $attrs = array()   X-Ref
Make nested HTML lists out of the items

The resulting list will look something like this:

<pre>
<<ul>>
<<li>><div class='tree_item parent'>(item contents)</div>
<<ul>
<<li>><div class='tree_item'>(item contents)</div><</li>>
<</ul>>
<</li>>
<</ul>>
</pre>

return: string HTML
param: array $items
param: array $attrs html attributes passed to the top ofs the list

search_box($id = false)   X-Ref
Returns a search box.

return: string         HTML with the search form hidden by default.
param: string $id     The search box wrapper div id, defaults to an autogenerated one.

navbar_plugin_output()   X-Ref
Allow plugins to provide some content to be rendered in the navbar.
The plugin must define a PLUGIN_render_navbar_output function that returns
the HTML they wish to add to the navbar.

return: string HTML for the navbar

user_menu($user = null, $withlinks = null)   X-Ref
Construct a user menu, returning HTML that can be echoed out by a
layout file.

return: string HTML fragment.
param: stdClass $user A user object, usually $USER.
param: bool $withlinks true if a dropdown should be built.

secure_layout_login_info()   X-Ref
Secure layout login info.

return: string

secure_layout_language_menu()   X-Ref
Returns the language menu in the secure layout.

No custom menu items are passed though, such that it will render only the language selection.

return: string

navbar()   X-Ref
This renders the navbar.
Uses bootstrap compatible html.


render_breadcrumb_navigation_node(breadcrumb_navigation_node $item)   X-Ref
Renders a breadcrumb navigation node object.

return: string HTML fragment
param: breadcrumb_navigation_node $item The navigation node to render.

render_navigation_node(navigation_node $item)   X-Ref
Renders a navigation node object.

return: string HTML fragment
param: navigation_node $item The navigation node to render.

rarrow()   X-Ref
Accessibility: Right arrow-like character is
used in the breadcrumb trail, course navigation menu
(previous/next activity), calendar, and search forum block.
If the theme does not set characters, appropriate defaults
are set automatically. Please DO NOT
use &lt; &gt; &raquo; - these are confusing for blind users.

return: string

larrow()   X-Ref
Accessibility: Left arrow-like character is
used in the breadcrumb trail, course navigation menu
(previous/next activity), calendar, and search forum block.
If the theme does not set characters, appropriate defaults
are set automatically. Please DO NOT
use &lt; &gt; &raquo; - these are confusing for blind users.

return: string

uarrow()   X-Ref
Accessibility: Up arrow-like character is used in
the book heirarchical navigation.
If the theme does not set characters, appropriate defaults
are set automatically. Please DO NOT
use ^ - this is confusing for blind users.

return: string

darrow()   X-Ref
Accessibility: Down arrow-like character.
If the theme does not set characters, appropriate defaults
are set automatically.

return: string

custom_menu($custommenuitems = '')   X-Ref
Returns the custom menu if one has been set

A custom menu can be configured by browsing to
Settings: Administration > Appearance > Themes > Theme settings
and then configuring the custommenu config setting as described.

Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_custom_menu()} instead.

return: string
param: string $custommenuitems - custom menuitems set by theme instead of global theme settings

custom_menu_flat()   X-Ref
We want to show the custom menus as a list of links in the footer on small screens.
Just return the menu object exported so we can render it differently.


render_custom_menu(custom_menu $menu)   X-Ref
Renders a custom menu object (located in outputcomponents.php)

The custom menu this method produces makes use of the YUI3 menunav widget
and requires very specific html elements and classes.

return: string
param: custom_menu $menu

render_custom_menu_item(custom_menu_item $menunode)   X-Ref
Renders a custom menu node as part of a submenu

The custom menu this method produces makes use of the YUI3 menunav widget
and requires very specific html elements and classes.

return: string
param: custom_menu_item $menunode

theme_switch_links()   X-Ref
Renders theme links for switching between default and other themes.

return: string

tabtree($tabs, $selected = null, $inactive = null)   X-Ref
Renders tabs

This function replaces print_tabs() used before Moodle 2.5 but with slightly different arguments

Theme developers: In order to change how tabs are displayed please override functions
{@link core_renderer::render_tabtree()} and/or {@link core_renderer::render_tabobject()}

return: string
param: array $tabs array of tabs, each of them may have it's own ->subtree
param: string|null $selected which tab to mark as selected, all parent tabs will
param: array|string|null $inactive list of ids of inactive tabs, regardless of

render_tabtree(tabtree $tabtree)   X-Ref
Renders tabtree

return: string
param: tabtree $tabtree

render_tabobject(tabobject $tabobject)   X-Ref
Renders tabobject (part of tabtree)

This function is called from {@link core_renderer::render_tabtree()}
and also it calls itself when printing the $tabobject subtree recursively.

Property $tabobject->level indicates the number of row of tabs.

return: string HTML fragment
param: tabobject $tabobject

blocks($region, $classes = array()   X-Ref
Get the HTML for blocks in the given region.

return: string HTML.
param: string $region The region to get HTML for.
param: array $classes Wrapping tag classes.
param: string $tag Wrapping tag.
param: boolean $fakeblocksonly Include fake blocks only.

custom_block_region($regionname)   X-Ref
Renders a custom block region.

Use this method if you want to add an additional block region to the content of the page.
Please note this should only be used in special situations.
We want to leave the theme is control where ever possible!

This method must use the same method that the theme uses within its layout file.
As such it asks the theme what method it is using.
It can be one of two values, blocks or blocks_for_region (deprecated).

return: string HTML for the block region.
param: string $regionname The name of the custom region to add.

body_css_classes(array $additionalclasses = array()   X-Ref
Returns the CSS classes to apply to the body tag.

return: string
param: array $additionalclasses Any additional classes to apply.

body_id()   X-Ref
The ID attribute to apply to the body tag.

return: string

body_attributes($additionalclasses = array()   X-Ref
Returns HTML attributes to use within the body tag. This includes an ID and classes.

return: string
param: string|array $additionalclasses Any additional classes to give the body tag,

page_heading($tag = 'h1')   X-Ref
Gets HTML for the page heading.

return: string HTML.
param: string $tag The tag to encase the heading in. h1 by default.

page_heading_button()   X-Ref
Gets the HTML for the page heading button.

return: string HTML.

page_doc_link($text = null)   X-Ref
Returns the Moodle docs link to use for this page.

return: string
param: string $text

supportemail(array $customattribs = [])   X-Ref
Returns the HTML for the site support email link

return: string The html code for the support email link.
param: array $customattribs Array of custom attributes for the support email anchor tag.

services_support_link()   X-Ref
Returns the services and support link for the help pop-up.

return: string

has_popover_links()   X-Ref
Helper function to decide whether to show the help popover header or not.

return: bool

page_heading_menu()   X-Ref
Returns the page heading menu.

return: string HTML.

page_title()   X-Ref
Returns the title to use on the page.

return: string

favicon()   X-Ref
Returns the moodle_url for the favicon.

return: moodle_url The moodle_url for the favicon

render_preferences_groups(preferences_groups $renderable)   X-Ref
Renders preferences groups.

return: string The output.
param: preferences_groups $renderable The renderable

render_preferences_group(preferences_group $renderable)   X-Ref
Renders preferences group.

return: string The output.
param: preferences_group $renderable The renderable

context_header($headerinfo = null, $headinglevel = 1)   X-Ref
No description

render_skip_links($links)   X-Ref
Renders the skip links for the page.

return: string HTML for the skip links.
param: array $links List of skip links.

render_context_header(context_header $contextheader)   X-Ref
Renders the header bar.

return: string HTML for the header bar.
param: context_header $contextheader Header bar object.

full_header()   X-Ref
Wrapper for header elements.

return: string HTML to display the main header.

context_header_settings_menu()   X-Ref
This is an optional menu that can be added to a layout by a theme. It contains the
menu for the course administration, only on the course main page.

return: string

build_action_menu_from_navigation(action_menu $menu,navigation_node $node,$indent = false,$onlytopleafnodes = false)   X-Ref
Take a node in the nav tree and make an action menu out of it.
The links are injected in the action menu.

return: boolean nodesskipped - True if nodes were skipped in building the menu
param: action_menu $menu
param: navigation_node $node
param: boolean $indent
param: boolean $onlytopleafnodes

region_main_settings_menu()   X-Ref
This is an optional menu that can be added to a layout by a theme. It contains the
menu for the most specific thing from the settings block. E.g. Module administration.

return: string

tag_list($tags, $label = null, $classes = '', $limit = 10,$pagecontext = null, $accesshidelabel = false)   X-Ref
Displays the list of tags associated with an entry

return: string
param: array $tags list of instances of core_tag or stdClass
param: string $label label to display in front, by default 'Tags' (get_string('tags')), set to null
param: string $classes additional classes for the enclosing div element
param: int $limit limit the number of tags to display, if size of $tags is more than this limit the "more" link
param: context $pagecontext specify if needed to overwrite the current page context for the view tag link
param: bool $accesshidelabel if true, the label should have class="accesshide" added.

render_inplace_editable(\core\output\inplace_editable $element)   X-Ref
Renders element for inline editing of any value

return: string
param: \core\output\inplace_editable $element

render_chart_bar(\core\chart_bar $chart)   X-Ref
Renders a bar chart.

return: string.
param: \core\chart_bar $chart The chart.

render_chart_line(\core\chart_line $chart)   X-Ref
Renders a line chart.

return: string.
param: \core\chart_line $chart The chart.

render_chart_pie(\core\chart_pie $chart)   X-Ref
Renders a pie chart.

return: string.
param: \core\chart_pie $chart The chart.

render_chart(\core\chart_base $chart, $withtable = true)   X-Ref
Renders a chart.

return: string.
param: \core\chart_base $chart The chart.
param: bool $withtable Whether to include a data table with the chart.

render_login(\core_auth\output\login $form)   X-Ref
Renders the login form.

return: string
param: \core_auth\output\login $form The renderable.

mform_element($element, $required, $advanced, $error, $ingroup)   X-Ref
Renders an mform element from a template.

return: mixed string|bool
param: HTML_QuickForm_element $element element
param: bool $required if input is required field
param: bool $advanced if input is an advanced field
param: string $error error message to display
param: bool $ingroup True if this element is rendered as part of a group

render_login_signup_form($form)   X-Ref
Render the login signup form into a nice template for the theme.

return: string
param: mform $form

render_verify_age_location_page($page)   X-Ref
Render the verify age and location page into a nice template for the theme.

return: string
param: \core_auth\output\verify_age_location_page $page The renderable

render_digital_minor_page($page)   X-Ref
Render the digital minor contact information page into a nice template for the theme.

return: string
param: \core_auth\output\digital_minor_page $page The renderable

render_progress_bar(progress_bar $bar)   X-Ref
Renders a progress bar.

Do not use $OUTPUT->render($bar), instead use progress_bar::create().

return: string HTML fragment
param: progress_bar $bar The bar.

render_progress_bar_update(string $id, float $percent, string $msg, string $estimate)   X-Ref
Renders an update to a progress bar.

Note: This does not cleanly map to a renderable class and should
never be used directly.

return: string ascii fragment
param: string $id
param: float $percent
param: string $msg Message
param: string $estimate time remaining message

render_checkbox_toggleall(\core\output\checkbox_toggleall $element)   X-Ref
Renders element for a toggle-all checkbox.

return: string
param: \core\output\checkbox_toggleall $element

render_participants_tertiary_nav(object $course, ?string $renderedbuttons = null)   X-Ref
Renders the tertiary nav for the participants page

return: string
param: object $course The course we are operating within
param: string|null $renderedbuttons Any additional buttons/content to be displayed in line with the nav

moodle_release()   X-Ref
Renders release information in the footer popup

return: string Moodle release info.

addblockbutton($region = '')   X-Ref
Generate the add block button when editing mode is turned on and the user can edit blocks.

return: string html for the add block button.
param: string $region where new blocks should be added.

Class: core_renderer_cli  - X-Ref

A renderer that generates output for command-line scripts.

The implementation of this renderer is probably incomplete.

header()   X-Ref
Returns the page header.

return: string HTML fragment

render_check_result(core\check\result $result)   X-Ref
Renders a Check API result

To aid in CLI consistency this status is NOT translated and the visual
width is always exactly 10 chars.

return: string HTML fragment
param: core\check\result $result

check_result(core\check\result $result)   X-Ref
Renders a Check API result

return: string fragment
param: result $result

render_progress_bar(progress_bar $bar)   X-Ref
Renders a progress bar.

Do not use $OUTPUT->render($bar), instead use progress_bar::create().

return: string ascii fragment
param: progress_bar $bar The bar.

render_progress_bar_update(string $id, float $percent, string $msg, string $estimate)   X-Ref
Renders an update to a progress bar.

Note: This does not cleanly map to a renderable class and should
never be used directly.

return: string ascii fragment
param: string $id
param: float $percent
param: string $msg Message
param: string $estimate time remaining message

heading($text, $level = 2, $classes = 'main', $id = null)   X-Ref
Returns a template fragment representing a Heading.

return: string A template fragment for a heading
param: string $text The text of the heading
param: int $level The level of importance of the heading
param: string $classes A space-separated list of CSS classes
param: string $id An optional ID

fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = "")   X-Ref
Returns a template fragment representing a fatal error.

return: string A template fragment for a fatal error
param: string $message The message to output
param: string $moreinfourl URL where more info can be found about the error
param: string $link Link for the Continue button
param: array $backtrace The execution backtrace
param: string $debuginfo Debugging information

notification($message, $type = null, $closebutton = true)   X-Ref
Returns a template fragment representing a notification.

return: string A template fragment for a notification
param: string $message The message to print out.
param: string $type    The type of notification. See constants on \core\output\notification.
param: bool $closebutton Whether to show a close icon to remove the notification (default true).

footer()   X-Ref
There is no footer for a cli request, however we must override the
footer method to prevent the default footer.


render_notification(\core\output\notification $notification)   X-Ref
Render a notification (that is, a status message about something that has
just happened).

return: string plain text output
param: \core\output\notification $notification the notification to print out

Class: core_renderer_ajax  - X-Ref

A renderer that generates output for ajax scripts.

This renderer prevents accidental sends back only json
encoded error messages, all other output is ignored.

fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = "")   X-Ref
Returns a template fragment representing a fatal error.

return: string A template fragment for a fatal error
param: string $message The message to output
param: string $moreinfourl URL where more info can be found about the error
param: string $link Link for the Continue button
param: array $backtrace The execution backtrace
param: string $debuginfo Debugging information

notification($message, $type = null, $closebutton = true)   X-Ref
Used to display a notification.
For the AJAX notifications are discarded.

param: string $message The message to print out.
param: string $type    The type of notification. See constants on \core\output\notification.
param: bool $closebutton Whether to show a close icon to remove the notification (default true).

redirect_message($encodedurl, $message, $delay, $debugdisableredirect,$messagetype = \core\output\notification::NOTIFY_INFO)   X-Ref
Used to display a redirection message.
AJAX redirections should not occur and as such redirection messages
are discarded.

param: moodle_url|string $encodedurl
param: string $message
param: int $delay
param: bool $debugdisableredirect
param: string $messagetype The type of notification to show the message in.

header()   X-Ref
Prepares the start of an AJAX output.


footer()   X-Ref
There is no footer for an AJAX request, however we must override the
footer method to prevent the default footer.


heading($text, $level = 2, $classes = 'main', $id = null)   X-Ref
No need for headers in an AJAX request... this should never happen.

param: string $text
param: int $level
param: string $classes
param: string $id

Class: core_renderer_maintenance  - X-Ref

The maintenance renderer.

The purpose of this renderer is to block out the core renderer methods that are not usable when the site
is running a maintenance related task.
It must always extend the core_renderer as we switch from the core_renderer to this renderer in a couple of places.

__construct(moodle_page $page, $target)   X-Ref
Initialises the renderer instance.

param: moodle_page $page
param: string $target

block(block_contents $bc, $region)   X-Ref
Does nothing. The maintenance renderer cannot produce blocks.

return: string
param: block_contents $bc
param: string $region

blocks($region, $classes = array()   X-Ref
Does nothing. The maintenance renderer cannot produce blocks.

return: string
param: string $region
param: array $classes
param: string $tag
param: boolean $fakeblocksonly

blocks_for_region($region, $fakeblocksonly = false)   X-Ref
Does nothing. The maintenance renderer cannot produce blocks.

return: string
param: string $region
param: boolean $fakeblocksonly Output fake block only.

course_content_header($onlyifnotcalledbefore = false)   X-Ref
Does nothing. The maintenance renderer cannot produce a course content header.

return: string
param: bool $onlyifnotcalledbefore

course_content_footer($onlyifnotcalledbefore = false)   X-Ref
Does nothing. The maintenance renderer cannot produce a course content footer.

return: string
param: bool $onlyifnotcalledbefore

course_header()   X-Ref
Does nothing. The maintenance renderer cannot produce a course header.

return: string

course_footer()   X-Ref
Does nothing. The maintenance renderer cannot produce a course footer.

return: string

custom_menu($custommenuitems = '')   X-Ref
Does nothing. The maintenance renderer cannot produce a custom menu.

return: string
param: string $custommenuitems

file_picker($options)   X-Ref
Does nothing. The maintenance renderer cannot produce a file picker.

return: string
param: array $options

htmllize_file_tree($dir)   X-Ref
Does nothing. The maintenance renderer cannot produce and HTML file tree.

return: string
param: array $dir

confirm($message, $continue, $cancel, array $displayoptions = [])   X-Ref
Overridden confirm message for upgrades.

return: string HTML fragment
param: string $message The question to ask the user
param: single_button|moodle_url|string $continue The single_button component representing the Continue answer.
param: single_button|moodle_url|string $cancel The single_button component representing the Cancel answer.
param: array $displayoptions optional extra display options

init_block_hider_js(block_contents $bc)   X-Ref
Does nothing. The maintenance renderer does not support JS.

param: block_contents $bc

lang_menu()   X-Ref
Does nothing. The maintenance renderer cannot produce language menus.

return: string

login_info($withlinks = null)   X-Ref
Does nothing. The maintenance renderer has no need for login information.

return: string
param: null $withlinks

secure_login_info()   X-Ref
Secure login info.

return: string

user_picture(stdClass $user, array $options = null)   X-Ref
Does nothing. The maintenance renderer cannot produce user pictures.

return: string
param: stdClass $user
param: array $options