I have a large number of books with images that I'm scanning and using image_import to import them in bulk. image_import doesn't support adding to a book as I import these images, and I am thinking that I might be able to do them after the fact using VBO instead. Each book has about 100 pages and I'm fine with going in and manually setting up the initial page in the book. This is not a feature I need to expose to my users so I'm fine with a one-off for now.
I don't see an option for this as a built in feature for VBO so I'd like to request it. In the meantime, I'm guessing I could use the option to execute some PHP code for each node instead. Can someone give me some pointers on how I can figure out what to do to try that?
Comment | File | Size | Author |
---|---|---|---|
#36 | book_actions.tar_.gz | 1.27 KB | joel_osc |
#25 | book_actions.tar_.gz | 1.18 KB | kenianbei |
#16 | book.action.inc_.txt | 746 bytes | kentr |
#9 | book.action.inc_.txt | 750 bytes | kentr |
#6 | book.action.inc_.txt | 714 bytes | kentr |
Comments
Comment #1
infojunkieI don't usually work on feature requests for actions because there's an infinite number of actions that can be needed. I'll keep this as postponed until someone picks it up or I need to implement it myself.
Comment #2
infojunkieComment #3
looplog CreditAttribution: looplog commentedI've attached book.action.inc which I used myself to achieve more or less the above poster's needs. It's ugly as sin, using direct database inserts and ignoring any logic the book module might contain for checking existing parents. But it works on nodes that have no existing book structure. You'll have to edit the file manually to add the mlid and the nid of the parent book. Hopefully the comments I've added should help with that if you don't know already how to do it.
I'm hesitant to put this up since I don't what hell it might cause to your database if you try to reparent a node that is already in a book. That being said it helped me out so here goes. To avoid problems I suggest you add the book depth field to your view, and only run this action on nodes with a depth value of 0. If you have a number a books to which you wish to add nodes and wish to save time, you can duplicate the action in both the info and action function with minimal changes.
To use, just rename as book.action.inc and place it in your vbo folder. If you get stuck, let me know. And as always, back up the database in case you do something wrong.
Comment #4
infojunkieThanks for your contribution omjn! It would be great if the original poster could try it. I will do so too.
Comment #5
pxlar8 CreditAttribution: pxlar8 commentedThis works great for me. Thanks for posting it--you saved me several hours of the tedium of manually adding hundreds of nodes to a book.
Since I couldn't get the Book Depth attribute of 0 to show any results, I created an imperfect workaround of adding a Book Depth column to my view so that I could at least visually see which nodes had already been assigned to a book.
Comment #6
kentr CreditAttribution: kentr commented@omjn,
Thanks for the base code.
Looks like you can get by with just this, which calls the API and hopefully avoids side-effects. I think it also avoids multiple entries if you process the same node twice, lets you move nodes from one book to another, etc due to the 'update' action.
(name changed for accuracy)
Comment #7
joetan CreditAttribution: joetan commentedjust to note, in the database table "menu_links", the menu entries that get added with this script are not entirely correct... the "module" column was set to "menu", when it should've been "book"
Comment #8
eiland CreditAttribution: eiland commentedUPDATE `menu_links` SET `module` = 'book' WHERE `menu_name` LIKE 'book-toc-%'
Comment #9
kentr CreditAttribution: kentr commentedUpdate: Due to menu issues reported in comments above, consider other solutions. Or build on this to solve the menu entry problems mentioned below. AFAIK, the first solution doesn't have the menu problems, but also doesn't fire any hooks when creating nodes.
Thanks.
Here's an untested update that sets
$node->book['module'] = 'book'
.Based on
menu_link_save()
, which is called frombook_nodeapi()
.Comment #10
eiland CreditAttribution: eiland commentedThanks Kentr but your update doesn't work.
syslog:
Cannot modify header information - headers already sent by (output started at /home/www/sites/all/modules/views_bulk_operations/book.action.inc:21) in /home/www/includes/common.inc on line 345.
Comment #11
asb CreditAttribution: asb commentedHi,
I think it is very important for VBO to fully support the core modules. Especially if it would allow to fix serious issues like those with book hierarchies (see issues linked below).
However, the action from #3 does not allow to add books to the parent level (
./book
) and thus needs some work ;)BIDs 34847 and 34848 were manually added to the book structure; they do appear at
./book
. NIDs 29877 and 7285 were attempted to be added to the book hierarchy through VBO but do not appear at./book
. Thus we're getting broken book structures which might lead into endless nightmares (see e.g. #645214: No menu links, no books and #467770: Book structure disappears repeatedly)The code from #9 still requires to manually edit the BID and PLID which makes it a bit imperfect action.
Any help to improve this action is gratly appreciated!
Thanks & greetings, -asb
Comment #12
asb CreditAttribution: asb commentedComment #13
kentr CreditAttribution: kentr commentedJust a note: remember that coding takes time, so if it's really a high priority to you, consider doing some coding or supporting the coders financially.
Sorry that I can't quickly work up a fix and do the testing for the faults in #9. Many other fires to put out right now.
Comment #14
kayceedub CreditAttribution: kayceedub commentedTo get rid of the
Cannot modify header information
... error, make sure there is no ?> at the end of your file.Otherwise, it works like a charm! Thank you very much Kentr!
Comment #15
tallsimon CreditAttribution: tallsimon commentedcould this help with the menu side of things? http://drupal.org/project/mew
Comment #16
kentr CreditAttribution: kentr commentedPer #14, removed the closing ?>, which violated the Drupal coding standards anyway. Problem was probably the blank line after the tag.
Comment #17
infojunkieWhile I would love to include this action in VBO, it requires to be made into a configurable action that allows selecting the book and parent node via a form.
Comment #18
asb CreditAttribution: asb commented@infojunkie: agreed!
Comment #19
Starminder CreditAttribution: Starminder commentedsubscribe - is there any way to use #16 in its current form? I've added it to the folder and "see it" under actions but I'm not putting 2+2 together to be able to use it, such as in content management filter so I can bulk add content to books. Thanks!
Comment #20
kentr CreditAttribution: kentr commented@starminder: Edit the numbers in these two lines as noted in the comments:
Comment #21
Starminder CreditAttribution: Starminder commentedThanks kentr. I've done this now, however, I still don't get an action I can use in Content Management Filter. I think I'm missing something else in the config, hopefully obvious....
Comment #22
kentr CreditAttribution: kentr commented@starminder: I misunderstood. I don't know if it will work with Content Management Filter.
Comment #23
Starminder CreditAttribution: Starminder commentedThanks - normally the bulk operations show up there as available. It's the same as 'Content', only it provides a bit more granularity.
I'm just thinking maybe I missed something obvious in the setup to make this work.
Comment #24
kenianbei CreditAttribution: kenianbei commentedHello all, I've taken the above code and made it into a configurable action. Unfortunately I'm not a pro PHP programmer, so please use with caution and please if you have time could you check my code for problems. I also have a version that works with OG.
You'll need to add to a custom module and change the parent book type that it will check. Sorry it's not more general, but I don't have time to change it around.
** I've removed the code since it was slightly defunct. I have a better version which I will be putting up soon.
Comment #25
kenianbei CreditAttribution: kenianbei commentedI've added a more generic and stable VBO action as a contrib module. It gives 2 actions, one to move node to new book, the other to remove node from all book outlines.
Comment #26
R-H CreditAttribution: R-H commentedIs there a way in VBO to take a book node and make it a new book in the book hierarchy?
Comment #27
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedsubscribe and testing
Comment #28
apmac CreditAttribution: apmac commented@#25 Tested on book with 540 nodes worked perfectly. Thanks very much.
Comment #29
infojunkieThanks all for the patch and reviews. Committed to latest dev.
Comment #31
ymeiner CreditAttribution: ymeiner commentedis there a chance to see it working on the drupal 7 version?
Comment #32
mzwyssig CreditAttribution: mzwyssig commentedSubscribe. I'd be very interested in this feature for D7
Comment #33
lolandese CreditAttribution: lolandese commentedComment #34
infojunkieComment #35
kenianbei CreditAttribution: kenianbei commentedI'd be willing to port since it wouldn't take much time...
Comment #36
joel_osc CreditAttribution: joel_osc commentedHere is a first crack at a port to D7, modifications are welcome.
Comment #37
ikeigenwijs CreditAttribution: ikeigenwijs commentedHey
I tried the port to Drupal 7 . I'm using dev version of VBO.
But I do not see a new action appearing.
I do have change value but book is not listed
Just to let you know.
How is vbo made aware of the new book function?
Comment #38
joel_osc CreditAttribution: joel_osc commentedAre the new actions listed in admin/config/system/actions ? If so then you may want to try flushing caches.
The call to hook_actions_info makes actions aware of the new actions:
I don't know if this will help but we are running VBO version:
; Information added by drupal.org packaging script on 2012-09-14
version = "7.x-3.0"
Let me know how it goes.
Comment #39
ikeigenwijs CreditAttribution: ikeigenwijs commentedthx for the fast response
I had a number of problems i think.
Here is what i did:
I did not have enable Actions permissions (VBO)
I have a tabbed module page, did not see it at first.
in .info
You can mark Actions permissions (VBO) as required
and Views Bulk Operations if they are required of course
In admin/config/system/actions i found the book actions
in advanced actions i can select move to book.
If this is the intended location for starting the configuration a pointer in that direction would be nice. I would never have found that.
For making use of the action i had to change the content2 view witch comes standard with vbo to make the new actions visible.
Imported 250 pages in a book ;-)
thx a lot
Comment #40
jlockhartJust wanted to say a big thanks. I installed the module from #36, flushed the cache, and added that action to my VBO.
Using: Views 7.x-3.7, Views Bulk Operations (VBO) 7.x-3.1
Worked flawlessly. Our use case was a client who was building a Celtic Knowledge 'book' in a WordPress blog. Needed to import over 530 posts to the Book content, unfortunately couldn't assign the parent at that time, but a little Views work, and the module above let me add all those book pages to a parent.
Worked Great. No errors, no issues.
Comment #41
pauldawg CreditAttribution: pauldawg commented#36 worked like a charm! Please submit this as an official project to Drupal. This is exactly what I needed, and would love to be kept up to date on any changes or enhancements.
Comment #42
pauldawg CreditAttribution: pauldawg commentedFYI the use case for this was syndicating content from another Wiki system, via Feeds module, and the content was arranged as a hierarchical book in the source system as well. Feeds will bring in the pages but not the book hierarchy, in the RSS, so this allows me to keep the hierarchy the same in both systems without too much effort. Thanks again!
Comment #43
bojanz CreditAttribution: bojanz commentedConverted #36 to a patch and committed it. Thanks!
(Small note: Had to remove the custom messages that are shown when the action is reported. We'll readd that once #1327632: Support action specific status message reporting. is ready)
Comment #44
wmfinck CreditAttribution: wmfinck commentedI am missing something. I have all of the required modules. I enabled the Book Operations module (# 36 above), I added the action. I cleared all the caches several times. The action will not show up in the drop-down lists on the Triggers page (under When content is viewed by an authenticated user). I am using Views admin pages. Suggestions are appreciated!
I have 2000 book pages to assign.
Edit: I should add that I am the only site user, so permissions should not be an issue.
Comment #45
joel_osc CreditAttribution: joel_osc commentedI don't know if I would be using the triggers page. Assuming the administration views module has been activated, I would make the action available to your admin/content page (admin/structure/views/view/admin_views_node/edit). Then, if you can come up with a filter that will show only nodes that you would like to move you can select all of your nodes at once and run the move to book action in bulk.
Comment #46
wmfinck CreditAttribution: wmfinck commentedjoel_osc thank you very much! I am familiar with Views but I was a VBO virgin until activating the module for the first time yesterday when I saw this thread. Now that I see how much more powerful some of its features are, I should have checked it out long ago. I followed your directions, and it worked wonderfully. This script is going to save me a lot of work migrating some D6 sites into D7.
I added five hundred pages to a dozen different books over my morning coffee. Thanks again!
Comment #48
Gletzer CreditAttribution: Gletzer commentedWe are using Drupal 7, and have been trying to implement the book action but when we activate the action in views it does not appear in dropdown as an operation. Any ideas what the problem could be? Any help would be greatly appreciated.
Comment #49
sonSticks CreditAttribution: sonSticks commented#36 works to move items to the root books, but it would be nice if you could select book parent as well.
I have a whole hierarchy of book pages that I would like to bulk update.