Determining if an item is not in a collection

Is there a way to see which items are not yet in a collection? Right now I can only see how I would determine this by having to scroll through each item's page.

There's not a built-in way to do this other than looking through the database itself. However, you could create a Simple Page with the following code, which should give you a list of the items that are not assigned to a collection. If it is not for public display, just leave the page not public.

A more elegant solution would be to build a simple plugin that creates the same thing as a real page in the admin.


$itemTable = get_db()->getTable('Item');
$select = $itemTable->getSelect();
$select->where("collection_id IS NULL");
$items = $itemTable->fetchObjects($select);

<?php while(loop_items()): ?>

<h2><?php echo link_to_item(item('Dublin Core', 'Title'), array('class'=>'permalink')); ?></h2>

<?php endwhile; ?>

Yes, there is. When you are browsing through items in admin (admin/items), click the "Show Details" link found to the right of "Toggle".

That expands the amount of item data displayed, including the collection it is in, and also would show if an item is not in a collection.

Oh, cool. Patrick's solution will be much quicker!

Thanks, Patrick and Sheila.

Patrick! This is wonderful! I want to hug you!

Is there a way of tweaking the code, Patrick, so that item links go to the admin page rather than the public show page? :) That'd make it easier to flick in and put the items in collections!

Something like this should do the trick, but it's starting to get a little dangerous. As long as it's just a few people who would be looking at that unpublished page, it should be fine. But if others end up getting there, it would be confusing to them.

At the top, put in:

<?php set_theme_base_uri('admin'); ?>

and at the end make sure you undo that change. if you don't it will break the site

<?php set_theme_base_uri('public'); ?>