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.

<?php
$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").'<br/>';
}
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

I am using it for about 2

I am using it for about 2 years.

Fantastic information,

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

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><div><img>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Use the special tag [adsense:format:group:channel] or [adsense:flexiblock:location] to display Google AdSense ads.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
5 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Powered by Drupal - Design by artinet