I am writing a custom module. On my module's configuration form I would like to provide links to relevant modules' configuration forms; e.g. the cron configuration form.

Is there a standard Drupal way to encode such links?
For instance is there a Drupal function that takes the menu path (eg. 'admin/config/system/cron') and provides an actual URL?


  • you can use the l function. url function is also available but while using in module l is a better option than url .
    – nit3ch
    Apr 9, 2013 at 20:19

2 Answers 2


For instance is there a Drupal function that takes the menu path (eg. 'admin/config/system/cron') and provides an actual URL?


print l(t('Cron configuration'), 'admin/config/system/cron');

Will print an a tag as follows:

<a href="/admin/config/system/cron">Cron configuration</a>

to the configuration with paths resolved correctly (works well when you have installed Drupal in a sub folder as well - just use the Drupal path).

If you are putting your own text, most likely that you are using t() function. Example:

$form['warning']['#makup'] = t('You need to make sure that you have setup a working !cron',
  array('!cron' => l(t('Cron configuration'), 'admin/config/system/cron')));

l() - Generates the anchor link (<a href="path/to/page">text</a>)

url() - Returns URL for a given Drupal path (l() calls this function to get the correct link)

See function reference for more configuration (absolute URLs, prevent using aliased path, etc)

  • 1
    Doh, think I got the wrong end of the stick there...
    – Clive
    Apr 9, 2013 at 20:52
  • @Clive Yup...me too >_<
    – Chapabu
    Apr 9, 2013 at 20:58

If a module has declared it's config form in the info file, I think you should be able to use drupal_parse_info_file();.

I'd probably get all the module names into an array, and then just run a foreach to get the paths.


*This is untested code that you should use as an example - there is no array error checking or anything like that:

function MYMODULE_get_config_pages() {
  $config_pages = array();
  $modules = array('cron', 'views', 'ctools', 'panels');

  foreach ($modules as $module) {
    $path = drupal_get_path('module', $module);
    $filename = $module . '.info';

    $info = drupal_parse_info_file($path . '/' . $filename);

    $config_pages[$module] = $info['configuration'];

  return $config_pages;

This will give you an array of module configuration pages, keyed by module name.

Next you'll want to run those links through l()


function MYMODULE_get_config_links($config_pages) {
  $links = array();

  foreach ($config_pages as $module => $uri) {
    // You might want to run $module through t() here or perhaps capitalise it.
    $links[] = l($module, $uri);

  return $links;

You could probably turn that into a neat little reusable object and bundle it with a module, but the above code should get you started :)

Please note, that I've not written any error checking for modules with no config pages declared in their info file! You might want to run an array_key_exists somewhere in the first function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.