In my custom Drupal module, I want to intercept the URL to show custom data derived from an external (in this case, XML) data source.
For example, let's say I wanted to create a Flickr front end on Drupal. I could browse photosets through my Drupal front-end, and I could comment on them (using node data inside Drupal).
If a user browsed to /flickrphoto/开发者_Go百科12345 - maybe I don't have any nodes in Drupal which corresponds to that URL, however, I want to intercept it and look up info on Flickr using data from the URL and NOT show a 404.
I can use the Drupal request_uri() in my module, but that doesn't seem elegant. I'd like to use path or pathauto as well, to all users to determine the URL scheme that directs to my module to ascertain the data that should be shown from the external source.
Thanks!
Since the 404 handle is done automatically in Drupal, you need to create a new entry that will match when the one from the custom module doesn't. This is done with hook_menu
. In the page callback you can handle what should happen when the node doesn't/do exist.
精彩评论