Drupal PHP Block - Aktivste Blogs

Bei Drupal können eigenen Blöcke auch mit PHP Code erstellt werden (ab Version 6 muss das Modul PHP Filter aktiviert werden). Damit ist es möglich diverse Arten von Blöcken zu erstellen.

Hier mal ein Beispiel-Block, der eine Liste der Blogs ausgibt die die meisten Beiträge enthalten.

<?php

$res = db_query("SELECT COUNT(uid) as count, uid FROM {node} WHERE type = 'blog' AND status = 1 GROUP BY uid ORDER BY count DESC;");

while ($dat = db_fetch_object($res)) {
$u = user_load(array('uid' => $dat->uid));
$links[] = array('title' => $u->name. '´s Blog', 'href' => 'blog/'.$u->uid);
}

print theme('links', $links, $attributes = array('class' => 'links'));

?>

Hinweis:
Das Modul "blog" sollte aktiviert sein.

Neuen Kommentar schreiben

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Textual smileys will be replaced with graphical ones.