Recent Topics – My First Drupal Mod

This site is developed on Drupal CMS. Today I though, I should show a block containing some recent posts like “Recent Comments” block. I searched drupal.org for long for any module. but i did not get. later, I have developed my first mod for drupal to show some recent topics/contents/posts.

How to do it:

1. Login as admin
2. Goto Administrator -> Site Building -> Blocks
3. Click “add block” link from top.
4. Enter “Recent Topics” in block description box
5. Write the following code in the block description box. You may change $list_no to any value.
6. Choose PHP code from Input Format section. This will not work, until you choose (you must have to enable it if not enabled).
7. Click Save Block
8. After saving, you will be redirected to block list. Most probably, you block is listed under Disabled category. Now choose a region for your block. You may choose Left Sidebar or Right Sidebar.
9. After selecting, click Save Blocks.
10. Go your homepage. You should now see the the recent topics.


$list_no = 10;

$query = “SELECT n.nid, n.title FROM
{node} n WHERE n.status = 1 ORDER BY
n.created DESC LIMIT $list_no”;
$sql = db_rewrite_sql($query);
$result = db_query($sql);
$output=”;
while($node=db_fetch_object($result)){
$output .= l($node->title,”node/$node->nid”).’
‘;
}
print $output;
?>

  • great..
    great..

  • I have just started using
    I have just started using Drupal CMS. Your mod for drupal looks great. I will use it.
    Thanks.

  • very nice post thank you
    very nice post thank you guys for sharing with us!

    I’m also think Dupal is best CMS.

    How long you guys using it?

    Regards

  • Fantastic information,
    Fantastic information, thanks a lot for sharing. Your entire blog is very useful…

  • hungrycoder

    I am using it for about 2
    I am using it for about 2 years.

  • Beautiful template.
    Beautiful template. Recommended. I am currently using WP, but am in the process of checking out Drupal. I will need to implement your solution. Thanks~!

  • This Drupal mode will be
    This Drupal mode will be quite helpful, thank you for supplying this mod to the rest of us. I am often looking for mods for Drupal and this one will be a nice addition to my collection.

  • I’m using it for 2 years
    I’m using it for 2 years also and is great

    Regards

  • I agree with you
    I agree with you

  • thanks for information…
    thanks for information…

  • I’m checking drupal too but
    I’m checking drupal too but still love WordPress

  • Great template – Thanks for
    Great template – Thanks for sharing

    Regards

  • thank u
    thank u

  • i read your article..the
    i read your article..the things you have written sound very sincere and nice topics i am looking forward to its continuation.

  • I also use Drupal to enhance our site and this is also what we are experiencing. Thanks for the tips!

  • Fantastic information,
    Fantastic information, thanks a lot for sharing.

  • major

    i tried this code ( ps – please include the opening <?php…) and got this result:

    PARSE ERROR: SYNTAX ERROR, UNEXPECTED
    T_STRING in
    (my site's path)\includes\common.inc
    (1537) : evel()'d code on line 4

    any ideas?