A friend of mine ran into this issue a while ago: Node listings like on the frontpage or for categories are not really themeable. The nodes themselves are, of course, but the list is not.

This makes it - at least - very hard, if you want for exampel surround all sticky nodes with a single div for design reasons. Or if want your node list to be a definition list, rather than a set of divs. Or...

Additionally, since a theme function is missing, there is a lot of duplicated code around Drupal modules that usually looks like this:

    $output = '';
    while ($node = db_fetch_object($result)) {
      $output .= node_view(node_load($node->nid), 1);
    }

Grep for "node_view(node_load(" on the sources to find all the occurences.

I therefore suggest to add a function theme_node_listing to node.module (the name "theme_node_list" is already occupied) to contain this code:

function theme_node_listing($result) {
  $output = '';
  while ($node = db_fetch_object($result)) {
    $output .= node_view(node_load($node->nid), 1);
  }
  return $output;
}

Note that the function takes a database result as argument.

The code mentioned above then can be replaced by

$output = theme('node_listing', $result);

Having centralized node listing formatting this way, the original problem of surrounding sticky nodes with a div can be solved by simply overloading the theme function in the theme engine of choice.

Comments

stevenpatz’s picture

Version: 4.7.3 » x.y.z

Features go in cvs.

gerd riesselmann’s picture

Priority: Normal » Critical

Since nothing happened here and 5.0 is already in Beta, I'm increasing priority of this.

I stumbled upon this missing feature on two other projects in the meantime. For example it is rather hard and ugly to place Adsense code within a node listing, so implementing the #1 web business model is unnecessarily complex.

I see no real reason to not provide this theme function and it also does not cause any compatibility issues. I therefore guess this request just has been overlooked. That's why I bring it up again, too.

dodorama’s picture

interesting

RobRoy’s picture

Version: x.y.z » 5.x-dev
Category: feature » support
Priority: Critical » Normal
Status: Active » Fixed

I suggest using the Views module http://drupal.org/project/views. Once you create a 'view' or a listing of nodes, you will be able to theme every aspect of it in your template.php and with your node-whatever.tpl.php files. Search around drupal.org for information on views.

gerd riesselmann’s picture

Status: Fixed » Active

Hmm, I'm not satisfied. While the answer itself might be a reasonable hot fix, if this was a bug report, it isn't for the feature request this is.

Views module is rather clumsy, at least for my taste. Introducing the theme function I suggested on the other hand makes live a lot easier, and is really simple to implement - and understand.

gerd riesselmann’s picture

Category: support » feature
dodorama’s picture

Can you make a patch out of it?
Maybe this would increase core-developer attention on this issue.

willmoy’s picture

Status: Active » Closed (won't fix)

I think now that everything's becoming views, the world has moved on?