1

So, after studying several examples, I started writing my own module to implement a notification-like entity.

I wanted it to allow separate bundles and be fieldable. This example was a great guide to me.

I've spend several hours and almost brought the wall down with my head due to the following issue though.

My implementation of hook_entity_info_alter:

function mymodule_entity_info_alter(&$entity_info) {
  foreach (notification_types() as $type => $info) {
    $entity_info['notification']['bundles'][$type] = array(
      'label' => $info->label,
      'admin' => array(
        'path' => 'admin/structure/notification-types/manage/%notification_type',
        'real path' => 'admin/structure/notification-types/manage/' . $type,
        'bundle argument' => 4,
      ),
    );
  }
}

to provide admin UI for my bundles, wouldn't work. It would provide "Manage Fields" and "Manage Display" tabs in my /admin/structure/notification-types list page with "broken" links such as /admin/structure/notification-types/manage/%25notification_type/fields.

Furthermore when I tried to manage fields of my bundles, I got a "page not found" error.

When I changed the 'path' array element to this:

'path' => 'admin/structure/notification-types/manage/%',

all of a sudden it worked, the wrong tabs went away and the bundles were manageable. My question: Why?!

1 Answer 1

1

GOT IT! After googling for a while I came accross this: http://drupal.org/node/224170

This clarifies that

"When a % symbol is used in a menu element (see example), the text that follows will be used to build the name of wildcard loader function.

In the example above, "%node" tells drupal to pass the value of the second element to the function node_load(). _load is always added by Drupal to construct the wildcard loader."

So as long as the notification_type_load() function wasn't implemented it lead to a bug :)

Your Answer

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