Custom Manager Pages

How to Get the ID of a CMP

hearty fare

CMP Id

How to get the ID of a CMP so you can use it in a Manager URL.

Everett asked...

Here's an ongoing problem I've encountered: how can I easily get the URL for a given CMP or some other manager controller?

The Solution:

sebastian-marinescu says...

The other solutions didn't work for me. I did it this way:

    $modx->getObject('modAction', array('namespace' => 'batcher'))->get('id')
  

What's the Story?

The URL to a Manager action page looks something like this:

  domain.com/manager/?a=workspaces

However, in many cases instead of the action name the URL will have the ID of the CMP, like this:

  domain.com/manager/?a=80

You can usually hover your mouse over the link to the CMP, then copy the URL, but the code above gives you the ID so that you can generate the URL in code (for example, in a Dashboard widget) without having to hard-code the ID.

If the CMP has any parameters that need to be added to the URL, such as for the MIGX CMP, you can find those by looking at its menu item in the Menus management page.