Actions

User

Gold/Docs/Anatomy of a Search Plugin

From Mahara Wiki

< User:Gold‎ | Docs
Revision as of 10:46, 19 May 2021 by Gold (talk | contribs) (Initial WIP on documenting a search plugin.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

tl;dr;

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.

htdocs/search/Mysearch
├── 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() :

Extras

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

Configuration