86 Important Drupal Snippets instead of Modules

There are times when all you want is a small functionality.  We tend to install a module which will give us much more, Then we become dependent on the module and updates to Drupal become more difficult or you have to wait till the contributed module releases and update to latest version. To avoid this its best to use PHP snippets for the job.

Showing Top Users and Snippets related to Users.

  1. "Most Active Users" and "Most Active Users This Week" block – This script doesn’t work in Drupal 6. But  you can get a starting point for highlighting your users.  Avoid User Points block in case you only want to display the Active / Top User
  2. Top X Commenters – I have tried this and works like a charm. Good alternative to Users Points Module.
  3. Top X Node Authors – I have tried this and works like a charm. Good alternative to Users Points Module.
  4. Custom "Who's Online" block for Drupal 6, showing IP and domain of guests too
  5. Custom "Who's Online," "Most Users Online" and "IP of Guest" blocks
  6. List users who have recently updated their blog
  7. Membership Status Block
  8. List Users From a Single Role in a Block
  9. List a site's users ranked by total pageviews that their content has received.


Content related blocks

  1. A "book-like" navigation block
  2. Book Module: How to make a book navigation block appear on all pages.
  3. Add node content into block depending on page ID
  4. Aggregator headline display with date
  5. All content types _except_ forum posts
  6. Alternative custom language block
  7. Automatic help block for nodes
  8. Block to identify content
  9. CREATE CONTENT navigation block
  10. Count register user, topics & post on the forum
  11. Display X most recent Twitter entries
  12. Display a menu or part of it
  13. Display latest 5 Guestbook entries
  14. Display latest X nodes from a taxonomy terms set
  15. Display latest X quiz titles with their creation dates
  16. Display random block
  17. List nodes tagged with a certain term
  18. Menu splitting into blocks
  19. Moving locked Navigation menu items to your custom block
  20. Latest topics from phpBB
  21. Node content
  22. Recently Viewed Content
  23. RelatedContent module: Block with links to related content
  24. Show a list of (x) most recent nodes from any of several categories (terms)
  25. Show a list of forums which contain the most popular forum posts
  26. Show block if inside specific book
  27. Show node attachments in a block


Vocabulary, Taxonomy , Terms

  1. Nested category links with node counts
  2. Nested category lists with links to term pages
  3. Nested category lists with node count and Parent > children node count\
  4. Block that displays terms in a vocabulary as a list of links
  5. List related terms
  6. Print a particular vocabulary's terms associated with node
  7. Create ComboBox related to taxonomy and nodes trought PHP on blocks
  8. Tag cloud with a count of the number of times a tag has been used
  9. Taxonomy Drop Down Jump Menu using Vocabulary and Terms for Block or Page
  10. Taxonomy filter block (including matching of child terms in hierarchical vocabularies)
  11. Taxonomy search with hierarchical select
  12. Show a list (x) of taxonomy terms with node counts
  13. Show a list of taxonomy terms without description
  14. related nodes to the current node by taxonomy term
  15. display the last (x) nodes associated with a vocabulary
  16. list most comment nodes in period of time only



  1. Anonymous user attachment warning message
  2. Attached images in a block

Blog related

  1. Blog Author Image, Name, and Signature (one php snippet to brand all blogs)
  2. Blogroll based on Weblinks, linking straight to destination
  3. Blogroll based on aggregator feeds
  4. My Blog link
  5. Show a list of all user blogs on the site



  1. Counter (x days before / past...)
  2. Block to do something based on day of the week
  3. Custom login
  4. Database Size
  5. Detect browser and display
  6. Displaying Search form Block in a custom theme file
  7. Fix E-Commerce Quicklist
  8. Generate random messages or user tips
  9. Geotargeting block
  10. Google Maps API in 6.x using Blocks and CCK Field
  11. How to show update availability for a windows program (written in Delphi) on a PHP/Drupal site ?
  12. Pull data from external database via term relation
  13. Simple HTML <select> using custom database tables.
  14. Simple form to email example
  15. Stay current with an always up to date © block
  16. Tiered Secondary Links
  17. Upcoming events
  18. Wordpress like category menu
  19. Comment approval count block
  20. Paypal blocks


Images , Video

  1. Images from node_images.module in a block
  2. Custom image block for an embedded gallery
  3. Latest (x) image in block
  4. Latest Video
  5. Latest Video with Thumbnail
  6. Random image from a particular category/gallery