Hi there,

Just took a look at the module. Useful feature :) However, can I just make a few notes/observations....

There are a number of places t() is missing (in a '#description' places and others.

Also, themers aren't going to like your module because it outputs a lot of html not using theme functions. By why of an example (I haven't tested this snippet, it's just to show you). In your hook_block(), for $op==view here's how I would do it:-

// just an extract from notepad_view() ....
// Notice it doesn't output any html. It collects the rows as before
// but then passes then to the theme function below which actually 
// does the rendering.
else if ($op == 'view') {
    if ($delta == 0) {
      // Generate block info - only show if have perms to use module
      if (user_access('can use notepad')) {
        $result = db_query("SELECT n.nid, ... <snipped long line>
        if (db_num_rows($result) > 0) {
          $rows = array();
          while ($row = db_fetch_object($result)) {
            $rows[] = $row;
          }
        }

        // Return the block info to be displayed
        $block['subject'] = 'Your Notes'; // MISSING t()
        $block['content'] = theme('notepad_block_content', $rows);
        return $block;
      }
    }
  }

This is the theme function you declare in your module. As you can see it does pretty much the same thing as your module (except I use l(), check_plain() and theme_list()). But now, because you have declared the output in a theme function of your own design themers can "get at it" and alter it's appearence by say defining phptemplate_notepad_block_content($row) {} in their template.php file in their theme.

// Notepad theme function for block content
function theme_notepad_block_content($rows) {
  $items = array();
  if (count($rows)) {
    foreach ($rows as $row) {
      $items[] = '<strong>'. l($row->title, 'node/'. $row->nid, array('title' => check_plain($row->body)));
    }
    $items = theme('list', $items);
  }
  else {
    $items = '<p align="center">None</p>';
  }
  return 
    $items .
    '<div align="center">:: '. l(t('view all notes'), 'notepad') .' ::</div>'.
    '<div align="center">:: '. l(t('add new note'), 'node/add/notepad') .' ::</div>';
}

You should consider using this technique for all html output so that themers can do what they like with the html rendering phase. As it stands, you cut them out the loop so they are likely not to use your module.

Comments

jondoesdrupal’s picture

Hi mate, thanks for taking a look, all good points.

I'll make some changes to better support translation and themeing and try to get it in place in the next few days.

Cheers,

Jon

jondoesdrupal’s picture

Component: User interface » Code
Assigned: Unassigned » jondoesdrupal
Status: Active » Fixed

As suggested, have gone through the code and made sure all output text is passed through t() and passed the output for the block through themed / themeable functions.

New release in the process of being released.

jondoesdrupal’s picture

Status: Fixed » Closed (fixed)

Fixes applied in ver 4.7.x-1.1