Skip to main content

Frankenstyle component names

The term 'Frankenstyle component names' refers to the naming convention that is used to uniquely identify a Moodle plugin based on the type of plugin and its name. They are used throughout the Moodle code (with a notable exception being the css class names in the themes).

Format

Frankenstyle component names have a prefix and then a folder name, separated by an underscore.

  1. The prefix is determined by the type of plugin. For example, the prefix for an activity module is mod.
  2. The name is the folder name of the plugin, always lower case. For example, the name for Quiz is quiz.

So the frankenstyle component name for the quiz module is mod_quiz.

Plugin types

See Plugin types page for the list of all supported plugin types in Moodle and their frankenstyle prefix.

To get a definitive list in your version of Moodle 2.x, use a small Moodle script with print_object(get_plugin_types());.

Core subsystems

Subsystems in Moodle are not plugins themselves but can be referred to using core_[subsystem.] where the subsystem defined in get_core_subsystems().

Other places that you may see these being used include:

  • the PHP Namespace used to autoload classes
  • the prefix used in JavaScript module names
  • the prefix used in template names
  • the @package parameter in phpdocs
  • the webservice function names

Core subsystems can provide own strings via a file stored in lang/en/{subsystemname}.php. Some of them have a dedicated location with libraries, autoloaded classes and other resources.

Core subsystemFrankenstyle component nameLocation
Accesscore_access
Administrationcore_admin/admin
Antiviruscore_antivirus/lib/antivirus
Authenticationcore_auth/auth
Conditional availabilitycore_availability/availability
Backup and restorecore_backup/backup/util/ui
Badgescore_badges/badges
Blockscore_block/blocks
Bloggingcore_blog/blog
Bulk users operationscore_bulkusers
Cachingcore_cache/cache
Calendarcore_calendar/calendar
Cohortscore_cohort/cohort
Commentcore_comment/comment
Competency based educationcore_competency/competency
Completioncore_completion/completion
Countriescore_countries
Coursecore_course/course
Currenciescore_currencies
Database transfercore_dbtransfer
Debuggingcore_debug
Text editorscore_editor/lib/editor
Education fieldscore_edufields
Enrolcore_enrol/enrol
Error reportingcore_error
Favouritescore_favourites/favourites
File pickercore_filepicker
Files managementcore_files/files
User filteringcore_filters
Formscore_form/lib/form
Gradescore_grades/grade
Advanced gradingcore_grading/grade/grading
Groupscore_group/group
Helpcore_help
Hubcore_hub
IMS CCcore_imscc
Installercore_install
ISO 6392core_iso6392
Language pack configurationcore_langconfig
Licensecore_license
Maths librarycore_mathslib
Mediacore_media
Messagingcore_message/message
MIME typescore_mimetypes
MNetcore_mnet/mnet
Dashboardcore_my/my
User notescore_notes/notes
Page typescore_pagetype
Pictures and iconscore_pix
Plagiarismcore_plagiarism/plagiarism
Plugins managementcore_plugin
Portfoliocore_portfolio/portfolio
Privacycore_privacy/privacy
Course publishingcore_publish/course/publish
Question bank enginecore_question/question
Ratingscore_rating/rating
Site registrationcore_register/admin/registration
Repositorycore_repository/repository
RSScore_rss/rss
Rolescore_role/admin/roles
Global searchcore_search/search
Tabular data display/download (deprecated)core_table
Taggingcore_tag/tag
Timezonescore_timezones
Usercore_user/user
User keycore_userkey
Web servicecore_webservice/webservice

Usage

Frankenstyle component names are used in:

Function names

All plugin functions must start with full frankenstyle prefix.

Activity modules

For backwards compatibility modules may also use modulename_ as prefix.

danger

Something about global functions not being recommended. Please use an autoloaded class.

Class names

All the component classes must be placed under the classes directory, which allows them to be (auto-loaded). These should be placed in a namespace according to their frankenstyle component name, and having a natural name, for example a discussion class in the forum activity should be in the mod_forum namespace and may have a class name of dicussion - \mod_forum\discussion.

Non-namespaced classes

The use of non-namespaced classes using only the frankenstyle prefix is now deprecated.

See Coding style for more information.

For example, the class. name mod_forum_example should be written as mod_forum\example.

Constants

All plugin constants must start with uppercase frankenstyle prefix, for example MOD_FORUM_XXXX.

note

The use of constants is not recommended and, where possible, a class constant on an autoloaded class should be used.

This allows uses of the constant to autoload the content without needing to manually require any files.

Table names

All table names for a plugin must begin with its frankenstyle name (after the standard Moodle table prefix).

danger

The exception to this rule is Moodle activities which (for historical reasons) do not have plugin type mod_ as a prefix to the plugin name.

Examples:

  • local_coolreport
  • local_coolreport_users
  • forum - for the mod_forum component

Plugin configuration table

In the config_plugins table, column plugin, the frankenstyle name is used.

Capabilities

All capabilities for a plugin use the frankenstyle name, except with a / instead of a _.

For example:

  • mod/quiz:viewattempt
  • block/library:readbook

Language files

The main language file for each plugin (with the notable exception of activity modules) is the frankenstyle component name.

For example:

  • /blocks/participants/lang/en/block_participants.php
  • /mod/quiz/lang/en/quiz.php

Renderers

Module Subplugins

It is possible to extend modules without having to change the basic module's code. See Subplugins for details.

Other places (TODO)

Please add more as they come up.

Theme name variants

Themes are typically a derivatives of some other theme. Where this is the case, you should avoid including the parent theme name in your theme's name.

See also