Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Feature: A Preview button that shows you the full page layout, with previewed content.
When creating a node, and you hit the 'Preview' button, just the content is previewed in the current form.
How about research into a contrib module, to allow the Preview button to show the page layout containing previewed content instead of just the content inside the current form.
Comment | File | Size | Author |
---|---|---|---|
#39 | fullpreview.zip | 4.01 KB | agentrickard |
#38 | fullpreview.zip | 2.62 KB | bluman |
#36 | fullpreview.zip | 2.18 KB | bluman |
#34 | fullpreview.zip | 2.17 KB | bluman |
#33 | fullpreview.module.txt | 2.69 KB | agentrickard |
Comments
Comment #1
vosechu CreditAttribution: vosechu commentedI like this idea a lot. Are you thinking a lightbox popup for preview?
Also, needs to conform to the task template.
Comment #2
aufumy CreditAttribution: aufumy commentedTask title: Full preview button.
Task description: A full preview button, allows the user to not just preview the node title/body modifications, but a full shot of the page including the blocks on a page, with the content replaced with the previewed content.
Deliverables: A contrib module for drupal 6, depending on modal frame api. Or maybe for drupal 7, mimicking /admin/structure/block/demo/bartik
Resources: http://code.google.com/p/google-highly-open-participation-drupal/wiki/Fu...
Primary contact: I can review, but there are likely better drupal core reviewers.
Comment #3
vosechu CreditAttribution: vosechu commentedAwesome, this is going to be great! Do you think this will be doable in a week or is it longer? Can you tag with gci-medium/hard/easy based on your feelings about it?
Also, from your history of contributions it seems like you should actually be the mentor or go a hunt down the core dev that you want to work with. Webchick isn't going to find the right mentor unless we ask her directly (I'm going to do the same in my issues as well).
Comment #4
aufumy CreditAttribution: aufumy commentedOk, will think about what mentors, I can suss out.
Comment #5
aufumy CreditAttribution: aufumy commentedComment #6
vosechu CreditAttribution: vosechu commentedCool, +1 from me then. I think this is a great idea and I hope that we can get this!
Comment #7
vosechu CreditAttribution: vosechu commentedComment #8
cwgordon7 CreditAttribution: cwgordon7 commentedAufumy, you can be listed as the primary mentor, and you can direct your student to other community members as necessary. This should be done as a module for Drupal 7, not for Drupal 6, so it can make use of the administration overlay as a dependency.
Otherwise, this looks great, thanks!
Comment #9
cwgordon7 CreditAttribution: cwgordon7 commentedHi aufumy,
Please make an account on the google application site and apply to be a mentor for Drupal, so I can add this task. It needs a mentor listed on the google system. You can apply here: http://socghop.appspot.com/gci/mentor/request/google/gci2010/drupal. Thanks!
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedHi aufumy,
Could you also estimate the time, in hours, that it would take a student to complete this task once it is claimed? This estimate is required to input the task into the google system.
Thanks!
Comment #11
dawehnerUpdate status, rtbc means it's ready to be pushed to melange :)
Comment #12
dawehnerhttp://www.google-melange.com/gci/task/show/google/gci2010/drupal/t12904...
This issue waits for a official mentor
Sent a message to aufumy.
Comment #13
vosechu CreditAttribution: vosechu commentedadding needs-mentor tag
Comment #14
webchickComment #15
bluman CreditAttribution: bluman commentedI took the task from GCI and I think I almost solved it. My idea is to add the node using a special flag in the database and allow the administrator to edit/modify and eventually save it and publish to the public. This would be like saving it without publishing, but in a easier way. At the moment I have implemented the button and the saving of the node with that special flag allowing the save and editing and have to implement a deletion of the previews older than one hour and also to somehow memorize the published/unpublished status as the preview flag overwrites it in the database. I think that to solve the second problem I'll implement a new column, but the sketch is done. Please tell me what you think about the idea. Also soon I will post the patch so you can all test it.
Thanks,
Paul Herman
Comment #16
bluman CreditAttribution: bluman commentedHere is the first upload. I think it's ready, please test it.
Comment #17
vosechu CreditAttribution: vosechu commentedI'm not close enough to core to know any better but is it possible to do this in a contrib module? I really want to see this in 7 but core patches are going to take forever to get in since we're in code freeze until 7 is out (and then features won't get wrapped in until D8 so that may be another year).
So is this even possible in contrib?
Comment #18
vosechu CreditAttribution: vosechu commentedPS. While I'm not really a great mentor for this I'm going to try to steward it a little bit so that you can get credit. I'll be asking for reviews in IRC but I would encourage you to talk to people in #drupal-contribute about this task since there's a lot of great developers in there.
Comment #19
agentrickardThe problem with this approach is that it introduces core changes to node module too late in the D7 release cycle. It also returns some old logic that we deliberately removed in D7.
Specifically this line change:
And the task itself specifically asks for a contrib module (not a core change) for precisely this reason.
You may be on to something with the pre-save trick, but then what if the node creation is abandoned? The loop through and delete on cron is a bit dicey. Really, what I think we need is a form_alter that intercepts the behavior of the 'Preview' button:
Changing the #submit callback should allow the generation of a popup preview or similar inside a custom module.
Comment #20
cwgordon7 CreditAttribution: cwgordon7 commentedSorry, bluman, I think agentrickard is right, this needs to be a contributed module. In fact, the issue specifically states that the deliverable is a contributed module. However, some of the code you've written will still be useful. Maybe you can turn this into a contributed module for Drupal 7?
Thanks!
Charlie
Comment #21
bluman CreditAttribution: bluman commentedI had to modify the access function, as I even think I have found a bug in it, it allows you to view unpublished nodes without being an admin or sth(not even logged in). About the module creation, could you point me to some tutorials as I'm new to drupal.
Comment #22
bluman CreditAttribution: bluman commentedHere is the first beta of the module. Please test it and submit me some feedback.
Comment #23
agentrickardWill do. I actually have a project that is perfect for testing this.
@cwgordon7 you want to add me as mentor for this one?
Comment #24
agentrickardWow. This code needs a refactor, given that there are curse words on line 4. Totally inappropriate and grounds for expulsion from GCI.
I'd still like to see this accomplished without saving the node to the db, is that even possible? Did you try?
There are also no Doxygen comments and some irregular use of code style.
See http://drupal.org/coding-standards
Note also that the 'preview' namespace is taken in Drupal CVS. http://drupalcode.org/viewvc/drupal/contributions/modules/preview/
Comment #25
bluman CreditAttribution: bluman commentedI'm sorry for that words. I was really angry about hiding the menu. Sorry. Also about the method without saving, I've tried to think about it, but haven't got any ideas. Could you delete the atachment temporarely to fix that line 4? Again sorry.
Comment #26
bluman CreditAttribution: bluman commentedHere is the version without that words. Sorry about them.
Comment #27
agentrickardWell, what does the normal "preview" action do?
Comment #28
bluman CreditAttribution: bluman commentedIt shows the content of the node in the current editing form without allowing to view the full node.
Comment #29
cwgordon7 CreditAttribution: cwgordon7 commentedAgentrickard, you can be the mentor for this, that's great actually. Bluman, you can contact agentrickard with any questions.
I believe it's impossible to do this without saving the node in the database, because there are contributed modules that may read directly from the database when deciding, say, which blocks to display on a page. The solution is to add a "preview" flag to the database that toggles something in node access that only allows the original author to see it.
Comment #30
bluman CreditAttribution: bluman commentedI've reviewed the code and I think that this version should be good. Please review it and give me feedback. Thanks for support cwgordon7 and agentrickard!
Comment #31
agentrickardHere's my problem with saving nodes in the database:
-- If you do that, you're really just saving an "unpublished" node. D7 already has a feature that allows authors to view their own unpublished nodes. So this approach doesn't add any benefit there. The menu handling is redundant, too, since unpublished nodes are not shown in the menu,
-- If you have to handle this as "unpublished" and the user has revisioning turned on, it will create a new revision on every node save, which is not the functionality that a "full preview" would try to accomplish.
-- If you have to set the node to "unpublished" to view the preview, then what happens when you want to preview changes to existing nodes? Then you would have to alter the active version id (vid) for the node, which can be very ugly to handle.
The normal chain in Drupal core is:
-- Press "preview" button.
-- Fire node_form_build_preview.
-- Fire node_form_submit_build_node.
-- Fire and theme node_preview.
What we might want to do is handle the preview form a little better by invoking the site theme instead of the admin theme and hiding the rest of the node form if $form_state['node_preview'] is not empty. Instead, we would present a 'Save' and 'Edit' button on the preview page.
If we can make that work, then we don't need any of the menu handling, the cron or the node access functions, all of which introduce edge cases that will be very hard to debug.
I'm going to test the existing code and make additional comments.
Comment #32
agentrickardIn this version of the code, the node is hidden at /node/NID but visible on /node IFF published and promoted (which is the default setting for new nodes). So that's not what we want.
We should also be able to provide Full Preview on existing nodes.
Comment #33
agentrickardHere's stub code that outlines the non-save approach, but leaves plenty of tasks TODO.
Comment #34
bluman CreditAttribution: bluman commentedHere is the version that is done through cache. Please test it and send me some feedback. The only "to do" is to make the editing in overlay.
Comment #35
agentrickardAn update of where we stand on this task, which was not clearly defined at the outset.
-- @bluman and I spent about an hour on IRC yesterday, reviewing possible approaches. We found three:
a) Save the node and display preview to the author only. This approach was rejected for security reasons, as described in #32 and #33. Saving the node is not the preferred method for generating a preview.
b) Use $form_state to display the node preview instead of the form, and provide SAVE and EDIT buttons to either save the changes or return to editing. This was promising, but we had some difficulty making the $form_state behave as expected; we also couldn't alter the page theme properly. We may return to this approach, but likely after GCI.
c) Save the temporary $node object created by the form to either a SESSION or CACHE variable. Then use a menu callback to generate a page that previews this copy of the $node object. @bluman has gone this route, using a callback to generate the preview from a copy of the node that is cached when the node is "previewed".
This (c) approach is what is under review now.
Goals:
-- New and existing nodes should be editable. Those edits should appear when the Full Preview button is submitted.
-- The Full Preview should open in a new window, a lightbox, or by loading a new page that does not disrupt the current state of the editing form.
-- The Full Preview should display the entire node page -- including the site theme, header navigation, sidebars and blocks -- so the editor can see the context of the changes.
-- From the Full Preview page, the editor should be able to go back to the edit screen. If possible -- but not a hard requirement -- the editor should be able to save the edits from the preview screen.
Comment #36
bluman CreditAttribution: bluman commentedHere should be the first usable build. Please review it. Thanks!
Comment #37
agentrickardAs I was afraid, using pnode/ for editing breaks the image uploader when editing an Article. The preview doesn't work for new images, either.
Still, we can work through that. I think we can mark this task as a success.
Opinions?
Comment #38
bluman CreditAttribution: bluman commentedI've added the comments and the mentor said that it is good.
Comment #39
agentrickardI made a few adjustments just for style and standards. A summary:
-- removed fullpreview.install, since that is unused.
-- cleaed up .info file for standards
-- moved drupal hooks to top of file, as best practice.
-- ensured proper spacing of Doxygen comments.
There is still some polish for this module, but as far as a research project, it's great. Uncovers many of the issues facing this process, and provides a nice basis to work from.
Marking as approved in GCI.
Comment #40
Les LimI just committed what is essentially a D6 implementation of approach (c) above a few days ago. I wish I'd come across this beforehand.
http://drupal.org/project/pagepreview
Combine efforts?
Comment #41
agentrickardDefinitely. Note that this was aiming at D7, so there wasn't quite a duplication of work.
The iframe trick in your code is a sneaky alternative to one of the problems we ran into.
Comment #42
saadshaukat CreditAttribution: saadshaukat commentedHi,
This module is superb. I have installed this module and it works fine for 'create content' or edit content forms. But I want to add a preview button to my custom form.
I have tried adding a preview button of a submit type and then calling pagepreview_node_form_build_preview when submitted using preview button.
It was first giving me an error that function node_form_submit_build_node is undefined but then I added this code module_load_include('inc', 'node', 'node.pages') to fix this issue. Now, form is submitted but it do not show the preview, instead it shows the form is saved message.
Can any one please direct me to the right direction to how I can use preview feature on my custom forms.
Many Thanks
Comment #43
agentrickard@saadshaukat
This was a student project, and I don't know if anyone is actively tracking it right now. If you are using Drupal 6, you might try http://drupal.org/project/pagepreview instead.
Comment #44
saadshaukat CreditAttribution: saadshaukat commentedhttp://drupal.org/project/pagepreview is same as this project.
Comment #45
agentrickardFile support issues over there, please. This is the student issue queue unrelated to the stable release.
Comment #46
knaffles CreditAttribution: knaffles commented