The plugin should contain an _admin.php file
:
if (!defined('DC_CONTEXT_ADMIN')) {return;} # add the plugin in the plugins list of the administration menu $_menu['Plugins']->addItem( # link name __('Example'), # base URL of the back-end 'plugin.php?p=example', # URL of the image used as an icon 'index.php?pf=example/icon.png', # URL regular expression preg_match('/plugin.php\?p=example(&.*)?$/', $_SERVER['REQUEST_URI']), # permessions needed to display the link $core->auth->check('usage,contentadmin',$core->blog->id));
Important:
In the previous code, remplaceexample
by the plugin directory's name. The icon should be 16×16 pixel wide, you can find some in the Silk Icons pack.
A link to the administration page is now visible in the sub-menu Extensions of the administration page:
Tip:
Besides the fact that the plugin defins general permissions in the _define.php file, it can sometimes be necessary to limit access to the back-end page to fewer users. For that purpose, you have to add afterif (!defined('DC_CONTEXT_ADMIN')) {return;}
the following code:
if (!$core->auth->isSuperAdmin()) {return;}
It is of course possible to adapt this code to specific permissions with the check()
function from the dcAuth
class.
Here is the base structure of the index.php
file. Note that the <html>
doesn't have any attributes : Dotclear adds them when the page is displayed.
<?php # insert PHP code here ?> <html> <head> <title><?php echo(__('Example')); ?></title> </head> <body> <h2><?php echo html::escapeHTML($core->blog->name).' › '. __('Example'); ?></h2> <?php echo(__('Hello World!')); ?> </body> </html>
Here is the result :