開発参考例 (Examples for Developers)

Events happening in the community are now at Drupal community events on www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

  

元記事URI http://drupal.org/project/examples
ステータス 作業中..
  どなたでも参加可能です
変更を行った場合は、ぜひコメントを残してください

This project aims to provide high-quality, well-documented API examples for a broad range of Drupal core functionality.

Developers can learn how to use a particular API quickly by experimenting with the examples, and adapt them for their own use.

News

  • 6 June 2010: Tests added for D7 Field Example
  • 27 May 2010: Added Menu Example (with tests) to both D6 and D7. hook_menu() in all its glory.
  • 23 May 2010: Thanks to coltrane, we now have a Queue Example.
  • 6 May 2010: Due to changes in core, if you have D7 simpletest_example or node_example installed, you may have to reinstall Drupal core to have them keep working. The versions here now do work with current HEAD.
  • 1 May 2010: There are now examples sites. They don't let you do everything, but they're useful: d7.drupalexamples.info and d6.drupalexamples.info.
  • 11 April 2010: Everything is now on API.drupal.org, thanks to the hard work of drumm. For example, go to api.drupal.org and search for "ajax_example".
  • 11 April 2010: Lots of new examples, including Image Examples (styles and effects) by eojthebrave, token examples for D7 by davereid, and form example (with #states and multistep forms) by rfay.

Example Module Status:

Name D6 D7 Tests
AHAH Example X
AJAX Example X
Batch Example X X X
Block Example X X X
Email Example X X X
Field API Example X X
Filter Example X X X
Form Example X X X
Form Element Example X X X
Image Example (styles and effects) X X
Javascript Example X
Menu Example X X X
Node API Usage Example X X X
Node Access Example X
Node Example (Custom Node type) X X X
Page Example X X X
Queue Example X X
Scaffolding Example (Database Record Usage) X
Simpletest Example X X X
Token Example X X
Trigger and Action Example X X X
Vertical Tabs Example X X X
XMLRPC Example X X X

How can you help? I'm glad you asked:

  • Most of all, we need you to file an issue every time you find an error or ambiguity or something that could be presented better.
  • We need additional examples.
  • We need reviews, corrections, and improvements to existing modules.
  • We need improvements in the doxygen comments.
  • We need help figuring out how to organize this growing mass of examples better, and how to improve the doxygen output on api.drupal.org.
  • Please feel free to help out in the issue queue.

Additional To-Do Wishlist of Examples:

  • Tokens example (D6, to match our D7 example)
  • Core widget example
  • File API example
  • Cache example
  • Security considerations example
  • Update/Upgrade system example

We also need tests for a number of the examples, especially for D6, and you can check the issue queue as well.

What examples do you need as a developer? Create an issue in the queue if you think there's a need.

If you have an example module and want to be added as a committer, just ask. If you'd rather submit a patch, do that in the issue queue.

Submission guidelines for patches and new modules

New example modules are welcome, and you can ask for CVS commit privileges if you want that.

All changes and submissions should be done first as a patch, whether or not you have commit privileges. This module is now being tested by the bot, so in order not to break things, it's important to post the patch first and make sure it passes.

  • Post as a patch before committing, to make sure your example passes.
  • The module must demonstrate a core feature. We'll get an "Examples" category together for contrib feature demonstrations later.
  • Drupal coding standards must be maintained.
  • Each module must have at least one menu entry, which leads to a page demonstrating the module. The menu entry should be 'examples/whatever'.
  • In general, do not require any permissions to use your module.
  • Remember that your example should be brain-dead simple. It's only job is to educate, certainly not to show off. Help the developer to understand the concept at hand.
  • Provide hook_help() to give some hints to the user.
  • Provide links to appropriate external documentation (including handbook pages, external pages, etc.) so that people can find where to go for more help.
  • Run Coder module on your module before submitting.
  • api.drupal.org is going to be picking up this code, so make sure that you have quality phpDoc. To see the results of your phpDoc right now, you can go to the temporary Examples API site
  • Our intent is that every module should have tests. Not only will the test keep the module maintained, but the test itself is also a great resource for developers.

We will probably need to have maintainers of the various modules, as core does, so if you're willing to "adopt" a module, please let let me know.

Honor Roll

(Ping rfay if you or someone else should be here and they're not!)

  • ilo has done an enormous amount of work, more than anybody else. He wrote nearly all the tests, and has added a number of modules. Thanks!
  • katbailey has done all of the javascript stuff and has added to the AJAX modules. Thanks!
  • davereid did the Token example and has contributed in dozens of other ways.

Downloads

Version Downloads Date Links
7.x-1.x-dev Download (95.48 KB) 2010-Jun-22 Notes
6.x-1.x-dev Download (52.91 KB) 2010-Jun-06 Notes

Resources

Development