Patrick Sullivan
Web Developer at Pickering Creative Group
Giant fan of all things Drupal
Family > Friends > Drupal > Vids > Beer
Search
7 is Lucky, 8 Breaks your Callback
I only seem to feel like writing after I've spent the afternoon bashing my head against a keyboard. Otherwise the day might only be worth a tweet.
While working on a flash component controller module today, I ran into another thing I did not know about Drupal's internals. The module required several screens for creating and editing parts of a flash banner, allowing for file uploads and re-ordering of the elements. Not the most complex thing ever, just a lot of administrative parts. I was happily crunching along when I began working on an edit screen for the elements. The path to that part of the module was:
admin/settings/splash3/element/edit/%/%splash3_banner/%splash3_element (see the 8 pieces?)
When visiting that path, the module would fall back to a path that it already knew:
admin/settings/splash3
?? - The game is afoot...
After trying several different callbacks and other changes to the module's hook_menu I finally hit on something. Things only started to get weird if I was passing an eighth menu arg to the callback. Shortening the path allowed them to work.
davereid confirmed my suspicions on the #drupal-nebraska IRC channel. Drupal can only accept seven parts of a path for a callback. See: http://api.drupal.org/api/constant/MENU_MAX_PARTS/6
Nice. So, all you aspiring module builders out there, don't get to crazy with your paths. You might just run into this little limitation in D6. If you are working in D7 already rest easy, you have nine menu parts to work with.


0 Comments