Gold/Docs/Anatomy of a Search Plugin

From Mahara Wiki

< User:Gold‎ | Docs
Revision as of 11:10, 20 May 2021 by Gold (talk | contribs) (→‎Configuration)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


This is intended to become a developer reference.

How to get your plugin seen by the system

The Plugin will live in the htdocs/search directory and needs to extend the PluginSearch class. As with all Mahara plugins the class is loaded from/lives in the lib.php file in the plugin directory.

├── lib
│   └── PluginSearchMysearch.php
├── lib.php
└── version.php

To keep things tidy we are adding a lib directory where the class files will live. This isn't strictly needed, but if your plugin is going to create multiple classes this is a way to keep the line count per file down to a manageable level. If you are only going to need one class though, skip this and just add it to the lib.php file.

The following methods need to be implemented by your Plugin.

  • search_user() :
  • search_group() :
  • group_search_user() :
  • self_search() :


  • Implement get_plugin_display_name() to give your plugin a human readable name.


Adding a configuration form is just a matter of implementing the following methods.

  • has_config() : Tells the system there is a config form. Shows the config cog on the Plugin Administration screen.
  • get_config_options() : Return a Pieform array.
  • validate_config_options(Pieform $form, $values) : Validate the user input from your config form.
  • save_config_options(Pieform $form, $values) : Save config options and react to any values entered.