Elgg offers a facility to manage your plugin pages via a page handler, enabling custom urls like
http://yoursite/your_plugin/section. To add a page handler to a plugin, a handler function needs to be registered in the plugin’s
start.php file with
The plugin’s page handler is passed two parameters:
- an array containing the sections of the URL exploded by ‘/’. With this information the handler will be able to apply any logic necessary, for example loading the appropriate view and returning its contents.
- the handler, this is the handler that is currently used (in our example
your_plugin). If you don’t register multiple page handlers to the same function you’ll never need this.
Pages in plugins should be served only through page handlers, stored in
pages/ of your plugin’s directory and do not need to
engine/start.php file. The purpose of these files are to knit together output from different views to form the page that the user sees. The program flow is something like this:
- A user requests
- Elgg checks if
plugin_nameis registered to a page handler and calls that function, passing
array('section', 'entity')as the first argument
- The page handler function determines which page to display, optionally sets some values, and then includes the correct page under
- The included file combines many separate views, calls formatting functions like
elgg_view_page(), and then echos the final output
- The user sees a fully rendered page
There is no syntax enforced on the URLs, but Elgg’s coding standards suggests a certain format.