×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: How to require the name of the author?

How to require the name of the author? 15 years 4 months ago #5006

  • Lucas Degiovani
  • Lucas Degiovani's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 13
  • Thank you received: 0
Hi...

I´m using 4.0beta1

I want to know if there´s a way to force the user to fill the "name" field when posting a new comment...

Can I change the code to do that??

I want to unregistered users to be able to post, I just dont want to let them do it with out filling the name field...

I want to show an alert if the field is blank... Just like when you don´t fill the message field...

Can anyone tell me what modifications should I do to the code??

How to require the name of the author? 15 years 4 months ago #5009

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
I tried having a quick look to see how it could be done, but I will need to ask Daniel for help with this :S

I am hoping we can have a backend option to specify which fields are optional or required for commenting in the next version 4.1.

How to require the name of the author? 15 years 4 months ago #5082

  • Lucas Degiovani
  • Lucas Degiovani's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 13
  • Thank you received: 0
Any word Jonus?

I too tried to have a look at the code but I didn´t have any sucess...

I tried some changes also but with no luck....

Have you talked to Daniel?

Thanks..

How to require the name of the author? 15 years 4 months ago #5119

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
I will provide a temporary, hard-coded solution for you to require the Name field - it will depend on JavaScript. If the user presses "Send" without entering a name, it will popup saying "Please enter a name" and not send.

I'll get back to you within 24-48 hours with the required code changes. As I said, it'll be hard coded - if you want to turn off the name requirement, you'll have to restore the original code.

I'll let you know soon :)

P.S. JoomlaComment 4.1, which is not scheduled for release anytime soon (main priority is bug fixing for 4.0), will hopefully contain options to specify which form fields are optional or required - and the new templates will also show whether they are optional or required with a nice icon next to the field.

How to require the name of the author? 15 years 4 months ago #5146

  • Lucas Degiovani
  • Lucas Degiovani's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 13
  • Thank you received: 0
Hi Janus,

Thanks for you support...

I´m not new to joomla, but I´m really not a programer....

I often try to find the solution by digging into the code... But this time i had no success...

I´l be waiting...

Thanks again....

How to require the name of the author? 15 years 4 months ago #5190

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
This actually wasn't too hard for me Lucas luckily ^_^

It's all done via the client.js file, located at /components/com_comment/joscomment/jscripts/client.js - at line number 389 or so, I inserted the following code:
if (form.tname.value == '')
    {
        alert("Please enter your Name");
        return 0;
    }

...and that's it! Tested and working! Obviously, this is English only and doesnt work on multi-language - it'd need about 3 file changes for multilanguage capability, then every language file would need to be updated with the new string....

Anyway, if you are using the public Beta 1 copy of !JoomlaComment, here is the modified file for you to use:
client.js

If you need support or help with JoomlaComment in future, please mention this thread in your new query so we know its a modified installation [just incase client.js needs to be edited, we will edit this one for you instead of the default one]. That can be easily done by pasting the link to this thread should you need assistance.

Hope it works well. Good luck and enjoy!

How to require the name of the author? 15 years 4 months ago #5191

  • Lucas Degiovani
  • Lucas Degiovani's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 13
  • Thank you received: 0
This was the file that I was trying to change... I see now that I was on the way.. Just needed a little push...

I Think I did some changes like yours, but i must have missed something. I don´t remeber exactly, but I think i was trying to use multilanguage support. I tried to use the same code that alerts when you don´t type any message... I´ll try this after lunch and get back to you...

Thanks...

How to require the name of the author? 15 years 4 months ago #5194

  • Lucas Degiovani
  • Lucas Degiovani's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 13
  • Thank you received: 0
It worked just as I needed...

And this modification was exactly what I tried to do before... But I placed the code after the alert of no message... And intead of typing the message like you did:

alert("Please enter your Name");


I tried the same alert of the "no message", just for testing...
alert(_JOOMLACOMMENT_FORMVALIDATE_EMAIL);

When I tested, after I typed some message and press sent, no warning was shown and I couldn´t send the comment...

Anyway, It´s working now..

Thanks for your help...

I was a very simple modification... Maybe some other people have this need...

And It can work with other fields, right? Just have to change the field name...
if (form.FIELDNAME.value == '')

How to require the name of the author? 15 years 3 months ago #5426

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
Lucas Degiovani wrote:

It worked just as I needed...
I tried the same alert of the "no message", just for testing...

alert(_JOOMLACOMMENT_FORMVALIDATE_EMAIL);


Well the way JoComment works is that, as it processes the code it replaces all those _JOOMLACOMMENT_* strings with the simple string replace command. Such code doesnt exist yet, JoComment has no idea to even search in the new popup check we created as it's not even aware it exists. I know what you're thinking though - basically the reason why it doesnt work is because it selectively replaces those strings when needed, rather than parsing the entire html output of JoComment (which would require less code and be easy to expand on, but would be horribly slow and server-draining :silly: )

Options to manually specify which fields are required or optional will be comming with 4.1 I believe (i'll be working on it regardless). The language files will also be updated to work with them.

Lucas Degiovani wrote:

And It can work with other fields, right? Just have to change the field name...

if (form.FIELDNAME.value == '')

Sure can! Any of the form names you can see in the template index.html file could be specified :)
  • Page:
  • 1
Time to create page: 0.109 seconds