Drupal has a module named Book Delete which you can use to delete books (along with all child pages). However, it doesn't appear to have an unpublish option and all I wanted to do was unpublish a book. Rather than writing a separate module, here are a couple of queries that should allow you to unpublish the entire book directly from the database.
This is for Drupal 7. Caveat emptor etc.
- List all books:
select b.bid, n.nid, n.title from book b INNER JOIN node n USING (nid) GROUP BY b.bid;
- List all books ordered by page count:
SELECT b.bid, COUNT(*) c FROM node n INNER JOIN book b USING (nid) GROUP BY b.bid ORDER BY c;
The bid above is the book ID (i.e., the nid of the top-most page, the cover) which is also obtainable from the first query. - Unpublish the entire book:
UPDATE node n INNER JOIN node_revision nr USING (nid) INNER JOIN book b USING (nid) SET n.status = 0, nr.status = 0 WHERE b.bid = 123;
The 123 above is the book ID of the book you want to unpublish. As you can see, we are unpublishing the nodes in both the node and node_revision tables. You might consequently see that the "affected rows" count is double or greater than the page count seen in the second query above. This is because rows in more than one table are being updated and some nodes might also have more than one revision.
Hope this helps :)
- Log in to post comments