Jump to content

shortcut to adding admin page in menus?


benbyf
 Share

Recommended Posts

For some unknown reason when you add an admin page as a child of one of the menu items e.g. Setup - the page doesn't appear in the Setup menu. I've had to do a hacker work around to make it work but was wondering what I needed to add to the module or page to make this happen, and what was the thinking behind this? As looking at the core code it looks as though this was done purposely.

Thanks!

Link to comment
Share on other sites

I'm not sure, but I was just quickly looking at two modules I've installed - apparently you can do it in two ways:

In the module file itself, getModuleInfo():

    public static function getModuleInfo() {
        return array(
            'title' => 'myModule',
            'version' => '0.1.1',
            'nav' => array(
              array(
                'url' => 'export/',
                'label' => 'Export',
                'icon' => 'arrow-right',
              ),
              array(
                'url' => 'import/',
                'label' => 'Import',
                'icon' => 'arrow-left'
              ),
              array(
                'url' => 'restore/',
                'label' => 'Restore',
                'icon' => 'reply'
              )
            )
        );
    }

taken from the great Migrator module (shortened)

Or with a JSON file named ModuleName.info.json:

{
	"title": "Module Name",
	"page": {
		"name": "db-backups",
		"parent": "setup", 
		"title": "DB Backups"
	},
	"nav": [
		{ "url": "backup/", "label": "New Backup", "icon": "plus-circle" },
		{ "url": "upload/", "label": "Upload", "icon": "upload" }
	]
}

taken from Ryan's Database Backup module.

  • Like 2
Link to comment
Share on other sites

1 hour ago, benbyf said:

what I needed to add to the module or page to make this happen, and what was the thinking behind this?

For modules, what @dragan said. Also in getModuleInfo(), you can add :

'page' => array(
	'name' => 'mymodulepage',
	'parent' => 'setup',
	'title' => 'MyModulePage'
),

 

Quote

For some unknown reason when you add an admin page as a child of one of the menu items e.g. Setup - the page doesn't appear in the Setup menu.

And how do you do that ?

The reason is because the page added require a ProcessModule to be defined.

Link to comment
Share on other sites

Will give that a go, thanks @flydev and @dragan.

Sorry I realised I was commenting on the wrong thing... with template admin and process added it shows up, but I wanted to simply add a link to an edit page for a page with a non-process template so that I could quickly edit settings on a page with lots of fields without having to make a whole process module to enable it...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...