Last updated October 20, 2006. Created by dman on October 20, 2006.
Log in to edit this page.
To help with managing a large amount of imported content, or when adding a required vocabulary to content that already exists, I found it needful to get a list of pages that hadn't been assigned to any terms yet.
Thanks to this post by Island Usurper, the following does so. This is an admin-only sort of utility. It just lists nodes that need to be looked at, and provides a link direct to their edit screen
Substitute $vocab_id and $content_type as required of course.
<?php
// An admin/content management utility.
// Make sure that everything is tagged with at least one term from the vocab
// SQL thanks to Island Usurper.
$vocab_id = 3;
$content_type = "page";
$result = db_query(
"SELECT * FROM {node} WHERE nid NOT IN (
SELECT nid FROM {term_node} AS tn
LEFT JOIN {term_data} AS td ON tn.tid = td.tid
WHERE td.vid = %d
)
AND type = '%s'",
$vocab_id , $content_type
);
$list = array();
while ($anode = db_fetch_object($result)) {
$list[] = l($anode->title, "node/$anode->nid")
. " " . l('[edit]', "node/$anode->nid/edit") ;
}
print theme('item_list',$list,"Pages with no classification at all");
?>Find pages not in the menu
Similarly, when searching for orphaned content, this version will try to show all pages that do not have a place in any menu.
It doesn't handle menus that link to aliases, but is a pretty good start for auditing a loose site.
<?php
// An admin/content management utility.
// List pages that have not been placed in the heirachy
$content_type = "page";
$result = db_query(
"SELECT * FROM `node` WHERE concat('node/',nid) not in (
SELECT path from menu
)
AND type = '%s'",
$content_type
);
$list = array();
while ($anode = db_fetch_object($result)) {
$list[] = l($anode->title, "node/$anode->nid")
. " " . l('[edit]', "node/$anode->nid/edit") ;
}
print theme('item_list',$list,"Pages not in the menu structure");
?>