Skip to content
Adam Patterson edited this page Apr 20, 2014 · 5 revisions

Introduction

Plugins from time to time may require settings, something like an API key, or maybe your analytics tracking code.

Assuming you have already gone over how to create a plugin you should know how to make a basic plugin by now.

To create a menu item on the admin screen under plugins/{your_plugin} could not be simpler.

First we will need to register an event under the name plugin_navigation, this will be triggered on the admin screen.

event::register('plugin_navigation', 'analytics::settings_nav');

The name of your function that is triggered by the action is not really important, but what is important is the contents returned.

<?php
class analytics
{

    static function settings_nav() {
        $nav[] = array(
            'title'     => 'Analytics',
            'route'      => 'analytics_settings',
            'uri'       => 'analytics/view'
        );

        $nav[] = array(
            'title'     => 'Analytics Two',
            'route'      => 'analytics_settings_two',
            'uri'       => 'analytics/view'
        );

    	return $nav;
    }
}

The array returned must have these three keys.

  • title The name to appear in the menu
  • route The route name admin/settings_plugins/analytics_settings
  • uri This is the path relative to the plugin folder containing the view. 'analytics/view' in this case

Your plugin folder would look something like this.

  • /analytics
  • /analytics/analytics.php
  • /analytics/view/analytics_settings.php
Clone this wiki locally