As I did a painful migration from SPIP to Drupal, I found myself with a lot of nodes that can't be accessed because they are attached to a taxonomy. Right now I can filter the most recent nodes, nodes needing approval, promoted or not promoted nodes, etc. It would be great to be able to filter only the taxonomy-less nodes in the content administration page.

Is there a quick way to do this in Drupal?

TIA.

Comments

TheLibrarian’s picture

I'll go ahead and implement this in taxonomy.module. The end result will probably look something like the "find orphan pages" functionality in book.module. If you can't wait for the patch, the SQL query that returns the right result is:

SELECT DISTINCT n.nid FROM node AS n LEFT JOIN term_node AS t ON n.nid = t.nid WHERE t.nid IS NULL;

TheLibrarian’s picture

Component: node system » taxonomy.module
Assigned: Unassigned » TheLibrarian
StatusFileSize
new2.77 KB

Here's a patch that will fix this. I'm recategorizing this under the taxonomy component because the changes are to taxonomy.module.

Patch features:
- New 'orphan nodes' item under administer/taxonomy menu.
- Displays table of nodes that have no taxonomy terms associated and that are not book pages.

Caveats emptor
- This function will be expensive for large sites. I imagine the big-O of array_diff_assoc is not great, and if you have a lot of orphans and/or book pages, this will come into play. This page won't be shown very often, however, so this is acceptable.
- array_diff_assoc requires PHP 4.3.0 and up, while array_diff requires PHP 4.0.1. I went with array_diff_assoc because it does an index check that is important to the current implementation. If required, I can backport the patch to support older versions of PHP.

TheLibrarian’s picture

Oops.. this patch is for cvs.

TheLibrarian’s picture

StatusFileSize
new2.85 KB

New patch version that sets the summary attribute for the table of nodes (gotta be spec-compliant).

TheLibrarian’s picture

StatusFileSize
new3.2 KB

Arrghh...

Ok, so here an ever newer version of the patch (sorry about this) that checks that modules exist before trying to query tables that may not exist. It also prunes project issues. Please let me know if I'm missing any node types.

TheLibrarian’s picture

Well... I'm a moron.

It appears I can't submit a simple correct patch today: every node can have associated taxonomy terms. This is what you get when Drupal-newbies submit patches. Since I can't trust my ability to code right now, I'm gonna wait until tomorrow to post yet another new patch for this. Please don't hurt me.

Gabriel R.’s picture

Librarian, you learn from your mistakes ;-)

Thanks for taking care of this, you rock!

moshe weitzman’s picture

This patch has too much special case handling which is inelegant. Why are nodes within book pages not considered 'orphans'. Also, the term 'orphan' usually has negative connotation, as if an admin has to do something about it. I don't think thats the case with these nodes.

Perhaps this is best handled in a Contrib module.

TheLibrarian’s picture

The special case handling goes away soon; it should never have been there (I have no clue what I was thinking).

As for the PHP version I said this patch requires: that goes away too, because it will no longer need to diff any arrays.

Because of the navigation issues, I think this will be appropriate for inclusion directly in taxonomy.module. The argument I use is my site. I have disabled archive browsing and the tracker for anonymous users. Because not every poster on the site can/will post directly to the front page, taxonomies are the only way for non-trusted users to really browse (sure they could use the search bar, but that's a horrible way to browse). The ability to see which sites are orphaned from the taxonomies is just as important in this case as seeing orphaned book pages. I believe that the original poster has a similar problem on his site, too.

TheLibrarian’s picture

StatusFileSize
new2.07 KB

And here is the patch, all pretty and tested, for your consideration.

Gabriel R.’s picture

I completely agree with TheLibrarian. As stated, I had the "orphan" problem while making a transition from another CMS, but the problem can occur on day-to-day use.

Please consider including this in the release versions.

Thanks.

dries’s picture

This functionality belong in the 'administer > content' menu. I suggest extending the existing filters.

ñull’s picture

Version: » 4.7.x-dev
Status: Closed (won't fix) » Active

Is there another module that is implementing this functionality? Weird that this idea has been dormant so long as if nobody needs this and as if everybody is so perfectly organised (not me).

mile23’s picture

Version: 4.7.x-dev » 4.7.0
Status: Active » Closed (won't fix)

This is eminently doable with Views and other solutions, plus D4 is unsupported at this late date.