Skip to main content

Articles tagged with "Drupal 5"

Altering drupal comments in hook_comment op = validate (drupal 5)

17th Feb 2009

One of those little Drupal annoyances this, there is now easy way to alter a comment (using hook_comment) before the comment is written to the DB. Hook comment is invoked during the validation phase, with $op set to "validate", and the comment array is passed by reference - but unfortunately any changes made to the comment are not passed on to the comment save function.

A quick and slightly dirty way around this is to make use of the global $form_values array and manipulate the comment directly in there - this little example will set an empty comment title...

Read more

Drupal node operations

7th Feb 2009

We love the views bulk operations module here at ComputerMinds, and frequently use it to create some lovely administrative interfaces.

However we often find a need for an administrator to be able to perform operations in a quick and easy way on an individual node. While some of the core operations (publish, make sticky etc) can be performed from the edit tab of the node, many other node operations do not offer this facility ("rebuild image thumbnails" for example).

So we have put together a simple module that exposes a form just like the one you get on the node...

Read more

Some nice quick views theming tricks in Drupal 5

27th Jan 2009

Thought I would post this little function on here, we tend to use it a lot and it gives some nice little extras for you to play with when you come to template your nodes.

  • $node->view_name : the name of the view this node is being rendered in
  • $node->position_in_view : the position within the view for this node

function phptemplate_views_view_nodes($view, $nodes, $type, $teasers = false, $links = true) {
  static $count;

  foreach ($nodes as $n) {
    $node = node_load($n->nid);
    $node->view_name = $view->name;
    $node->position_in_view=$count[$view->name];

    $count[$view->name]+=1;
    $output .= node_view($node, $teasers, false, $links);
  }
  return $output;
}
Read more

Making a drupal views block title link back to the view

24th Jan 2009

One for the small but handy category this. The standard "more" link the views module adds to it's blocks has no place on a modern accessible website, you really need a more verbose link in there. One solution has always been to add a bit of footer or header text into the block, but it's a little tedious - and clients always find views hard to edit.

This simple solution will turn the block title into a link to the view, it goes into your template.php _phptemplate_variables function


  if ($hook=='block'){
    $block = $vars['block'];
    if ($block->module == 'views'){
      $view =...
Read more