"Knowledge is not necessarily wisdom." Proverb from Ancient Egyptian Temple
I needed to make a block in drupal that contain my recent posts and so, I write this code snippet.
<?php
// Get all node IDs and it title from the "node" table
// Customize the types retrieved from the "type" field
// (Status=0 & Moderate=0) mean the post is published
$result = mysql_query("SELECT nid, title
FROM node
WHERE (type='story' or type='blog'
OR type='flexinode-1')
AND NOT (status=0 and moderate=0)
ORDER BY nid DESC")
or die(mysql_error());
echo
"<ul>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print node titles linked to its page into unsorted list
echo "<li>";
echo "<a href=\"http://ikhnaton2.com/
node/{$row['nid']}\">$row['title']}</a>";
echo "</li>";
}
echo "</ul>";
?>Enjoy :)
Another trick: Display a list of node titles from a specific category
Very helpful function to convert date/time string to Unix timestamp. I needed this function to update the timestamp field of some comments in my Drupal after migrating them from my blog on blogspot.
Recent comments
12 min ago
2 hours 11 min ago
9 hours 40 min ago
2 days 17 min ago
4 days 8 min ago
2 weeks 1 day ago
2 weeks 2 days ago
3 weeks 1 day ago
3 weeks 2 days ago
3 weeks 2 days ago