Created
April 18, 2013 21:27
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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