Hello,
I've config node_gallery and created galleries that have several images. However, I noticed that when I unpublish the gallery node the images in the gallery remain published, so they still show up on the search results and views.
Thanks in advance for your help,
KH
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | batch-publish-toggle.patch | 2.33 KB | justintime |
| #5 | node-gallery-cascade-publish-batch.patch | 3.7 KB | scroogie |
| #1 | node-gallery-cascade-publish.patch | 1.44 KB | scroogie |
Comments
Comment #1
scroogie commentedMhm, we can do this with Triggers/Actions Bulk API, some manual loading and saving of nodes, or directly in the database. I'll leave this decision to justin. Here is a patch to directly do it in the database.
Greetings
scroogie
Comment #2
3dloco commentedThanks Scroogie for your patch, really appreciate it! Your patch does effectively unpublish all the images when the gallery is unpublished.
However, when the images in a gallery are unpublished they disappear from the manage images tab (node/*/images). Also, on views the image count field is displaying 0 when unpublished and the right image count when published.
Thank you very much for your help,
KH
Comment #3
scroogie commentedAh, you're right indeed. I guess the manage and sort images tab should show unpublished images.
The image count is correct in my opinion, because unpublished images are just that: unpublished. They shouldn't be counted for images in a gallery, or do you think differently?
For now, you can change the manage images thing in the related View, but I guess we should change the default. Justin, what do you think about that?
Comment #4
justintime commentedOK, so for the manage and sort issue, I created #956638: Unpublished images don't show up in Manage and Sort tabs.
Agree with the image count being correct. Anonymous users should not see any data related to unpublished nodes.
Regarding your patch, it works, but there's problems with going the direct to the db route. The problem is that other modules may want to perform operations on these nodes when they are unpublished, and you're bypassing nodeapi by going that route. Instead, we should node_load()/node_save() each image that needs modified. Since that's a fairly expensive operation and there's the potential for 100's or even 1,000's of images here, we should use batch API. Code similar to the cascading deletion should do well here.
Also bumping this to critical so it makes the alpha.
Comment #5
scroogie commentedSo perhaps we should show a confirmation dialog for this?
This one is with batch API. I reused the node_gallery_batch_node_save function that was already there.
Greetings
scroogie
Comment #6
3dloco commentedThanks Scroogie! This is currently working for me!
--After saving the gallery (changing status from published to unpublished and viceversa) the progress bar (batch API) show the progress and all the images for the gallery are unpublished or published, respectively.
--Also, the images now appear on the manage images page even when the gallery is unpublished.
Thank you very much for your help, really appreciate your hard work :-)
Comment #7
justintime commentedNice patch @scroogie - I didn't know PHP had anonymous functions - reminds me of my Perl days :)
I cleaned a bunch of stuff up and rerolled it. Not much functional difference, just a lot less repeating ourselves. @3dloco (or anyone else), could you test the updated patch and report back?
Comment #8
justintime commentedsetting status back to needs review
Comment #9
scroogie commentedAh, yes, thats better indeed. But are the escaped variables on purpose?
Comment #10
justintime commentedYeah, that's intentional. I needed $status to be interpolated, but the other variables to not be. The php.net docs for create_function explain that variable interpolation is usually prevented by using single quotes, but I had to switch to double quotes to allow interpolation of $status. Thinking about it now, I probably should have used $status as an argument. Oh well.
Comment #11
3dloco commentedHello Justintime
Patch #7 is currently working for me. Thanks a lot for help!!
Regards,
KH
Comment #12
justintime commentedSweet. Committed to dev with the changes mentioned in #10 for clarity