Jump to content

Prestashop Module Development


prestashopnew

Recommended Posts

Hello everyone, I'm reading this book:

 


 

I have a problem.

 

The book guides you in creating a module that allows users to add a comment in the product screen.

I got to page 32 which explains how to view comments.

I can enter and view the written comment, but every time I refresh the page, the comment is duplicated automatically.

Any of you know the book or know how to solve this problem? Thanks in advance.

 

This is the displayProductTabContent.tpl file


 

Thank you

Link to comment
Share on other sites

as @kalifsoup has mentioned, when you refresh the page, actually the form will be submitted again, usually you see a confirmation popup window from browser about the re-submit the data.

here what you can do to avoid this 

1. after process the data, redirect to URL to the same page, so even user refresh the page, it will not resubmit the data again,

2. change to use ajax to post data and process in ajax method, only update the page partially instead of post whole page back

Link to comment
Share on other sites

Thanks for both answers.

I do not know very well ajax so I would not know how to do.

 

I know the html but still I can not fix, I tried to rediret to the same page after sending data, but if I refresh the page, the last comment continues to duplicate itself endlessly.

I tried to put in action the address, or the onSubmit method, even the hidden input type, but still nothing.

Edited by prestashopnew (see edit history)
Link to comment
Share on other sites

Unfortunately I have not an experienced programmer, but I just noticed that it is a general problem. Even when I subscribe to the newsletter and then I update the page without typing anything, the module tells me that I have already registered, because it resends the data.
 
So it's not a problem of my module?
 
This is the php files of my module

http://dpaste.com/3DDFJ84

Edited by prestashopnew (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...