Add new category and custom page into Site Administration menu

Add new category and custom page into Site Administration menu

by Anthony Nguyen -
Number of replies: 0

Hi everyone,

I'm trying to add a new feature into site administration menu of moodle as part of a project that I am working on. Right now our customer only needs to integrate OnePay gateway into moodle. But in the future, they may require integration of other payment gateways (like PayPal) as well. So I need to create a category just for website administrators to input different types of payment. A new category should be somewhere in the "Advanced Features" menu (something like in the following screenshots)


Where to add new category


Example for OnePay Integration


With "Settings" page is a page that site administrator to input all necessary payment information (including customer's card number, access code, etc.). Right now I'm testing with using two of my testing pages for domestic and international payments.

Here is my code in file /lang/en/admin.php:

$string['payment'] = 'Payment';
$string['onepay'] = 'OnePay';
$string['test_onepay_domestic'] = 'Test Domestic Payment using OnePay';
$string['test_onepay_international'] = 'Test International Payment using OnePay';


In admin_custom directory, I created a path like this /payment/onepay/test/ and add 2 my testing pages into it. In folder /payment/, I added a file named menu.php. Here is my code in it.


<?php
$ADMIN->add('advancedfeatures', new admin_category('payment', get_string('payment', 'admin')));
    $ADMIN->add('payment', new admin_category('payment', get_string('onepay', 'admin')));
    //$domestic = new admin_settingpage('onepay', new lang_string('test_onepay_domestic', 'admin'), new moodle_url("/admin_custom/payment/onepay/test/domestic/index.php"));
    //$international = new admin_settingpage('onepay', new lang_string('test_onepay_international', 'admin'), new moodle_url("/admin_custom/payment/onepay/test/international/index.php"));

$domestic = new admin_externalpage('test_onepay_domestic', get_string('test_onepay_domestic'), "$CFG->wwwroot/admin_custom/payment/onepay/test/domestic/index.php");
$international = new admin_externalpage('test_onepay_international', get_string('test_onepay_international'), "$CFG->wwwroot/admin_custom/payment/onepay/test/international/index.php");

$ADMIN->add('onepay', $domestic);
$ADMIN->add('onepay', $international);

I have attempted to include file menu.php in both files

  • /admin/settings/top.php
  • /admin/settings/server.php

But none of these works. Can anyone please tell me what should I do to get this works? Thank you very much. I really appreciate that.


Average of ratings: -