Forum Moderators: coopster

Message Too Old, No Replies

Preview changes

Before saving to MySql

         

wheelie34

3:48 pm on Apr 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi

I need to add a "Preview" button to my property editing page as owners are saving some wonderful blunders. Ideally I would want to force them to preview before saving, the preview should open in the property template, or a copy of it, so they can see how it will look.

My edit_property page pulls data from the mysql db and populates the text areas/fields etc, I have a Save changes button which then takes the content to another page, update.php which writes the submitted data to the db and emails me a note so I can check the blunders.

I can't find any info on previewing, is it easy to do, where do I start?

Is it as simple as posting it to a template which would, if submitted, send it on to update.php, create a page in between?

cameraman

4:05 pm on Apr 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, it could be that simple. You could either resubmit the data (possibly as hidden) from the preview page, hold the data in $_SESSION, or, what I think I'd do, go ahead and insert the data with a 'pending' field set to true. If the owner accepts the preview then just clear the pending flag, and if not, return him/her to the edit page and retrieve the data from the table for further edit - I'd have a hidden field in the form telling me that it's already in the table so I don't INSERT it again - having stored the record ID either in $_SESSION or that hidden field.

idfer

10:15 pm on Apr 2, 2008 (gmt 0)

10+ Year Member



For previews, the easiest is to add the edit form to the bottom of the preview page with the fields prepopulated. This way the user can look at the preview and make changes without flipping between pages. Otherwise put them in hidden fields as cameraman mentioned. With either of these two methods, the user can have multiple "threads", i.e. windows, where they can work on several posts simultaneously.

If you put the data in $_SESSION, be careful or you may get unexpected results if the user previews one post, opens a new window and previews another post, then returns to the first one and clicks on submit.

cameraman's 'pending' field idea is pretty good too, but you'll need to clean the database periodically to get rid of pending posts that were abandonned.

Hope this helps.

wheelie34

7:56 am on Apr 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks both of you for your replies.

I went with cameramans idea, I created a new column "active" Yes/No while they are editing it is set to Yes but as soon as they "preview" (which actually saves all data to the db and sets the active column to No) only after they submit or approve their changes the page issues an UPDATE command to set active to Yes.

Seems to be working