Skip to content

Instantly share code, notes, and snippets.

@cdmo
Created April 18, 2013 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdmo/5416370 to your computer and use it in GitHub Desktop.
Save cdmo/5416370 to your computer and use it in GitHub Desktop.
To discover information about the nodes in a given type. Something I'm cooking up to keep a better eye on important things in Drupal.
<?php
/**
* To discover information about the nodes in a given type
* @param $type a string, choose a content type machine name
* @return a string
*/
function get_nodes_statuses($type) {
$result = db_query('SELECT n.nid, n.title, n.changed FROM {node} n WHERE n.type = :type', array(':type' => $type));
$i = 0;
if ($result) {
while ($row = $result->fetchAssoc()) {
$node_status[$i][] = $row['nid'];
$node_status[$i][] = $row['title'];
$node_status[$i][] = date('F j, g:ia' ,$row['changed']);
$i++;
}
}
$device_lines = "";
foreach ($node_status as $individual_node) {
$device_lines .= $individual_node[1] ."\t". $individual_node[2];
}
return "total: ". $i ."\ntitle\tlast modified\t\n". $device_lines;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment