Drupal Planet

Selection of postings suitable for Drupal Planet feeds.

Make sure your modules actually work before applying

Here's a snippet from a recent application...

  1. /**
  2.  * Implementation of hook_menu().
  3.  */
  4. function foo_menu($may_cache) {
  5.   $items = array<();
  6.   if ($may_cache) {
  7.     $items[] = array<(
  8.       'path' => 'admin/settings/foo',
  9.       'title' => t('Foo settings'),
  10.       'callback' => 'system_admin_menu_block',
  11.       'position' => 'right',
  12.       'description' => 'Define Foo Module Settings',
  13.       'acces' => user_access('Access Foo Module'),
  14.     );
  15.  
  16.     $items[] = array<(
  17.       'title' => t('Foo Page'),
  18.       'path' => 'foo_video',
  19.       'callback' => 'foo_page',
  20.       'access' => TRUE,
  21.     );
  22.   }
  23. }



Sod translators, abuse t()

Not all CVS application reviews result in a decline of the application. Many get through even though it contains some "bugs". Here's an example that is in some sense classic.

Lets look at a snippet...

  1. $warning = variable_get('foo_warning', NULL);
  2.  
  3. $tokens = array<(
  4.   '%user' => $account->name,
  5.   '!edit_url' => url('user/'.$account->uid.'/edit',array<('absolute'=>TRUE)),
  6.   '%expiry_date' => date<("F j, Y", $expiry_date),
  7.   '%days_left' => round<(($expiry_date - $today[0]) / 86400),
  8. );
  9.  
  10. // ... and then
  11.  
  12. drupal_set_message(t($warning, $tokens), 'warning');



Play nice when binding to node types

At one time or another you're going to come up with a great piece of minor functionality that binds itself to a node in some cunning way. Here we'll explore the one most common methods to achieve this; throwing your crap straight into the node build process. You could attach it via a node link also but this article is looking at the badness made in a recent CVS application. So we'll stick with a that to keep things short.

So what has this to do with interoperability and node types? Well, not a lot actually, it's more about playing nice with node types and how you attach your cruft to them.

Take this wonderful snippet lifted from a recent application:

  1. function foo_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  2.  
  3.   // ... do something funky and put it in $my_cruft ...
  4.  
  5.   $node->content['foo'] = array<(
  6.     '#value' => $my_cruft,
  7.     '#weight' => CONST_NO_ONE_CAN_CHANGE,
  8.   );
  9. }



Syndicate content