Posted by shenzhuxi on September 9, 2009 at 9:20am
Issue Summary
A patch for add limit comment length to maxlength module.
| Attachment | Size |
|---|---|
| maxlength.patch | 3.77 KB |
A patch for add limit comment length to maxlength module.
| Attachment | Size |
|---|---|
| maxlength.patch | 3.77 KB |
Comments
#1
Cool.
+++ /var/www/sugargoss/sites/all/modules/maxlength/maxlength.module 2009-09-09 17:14:34.000000000 +0800@@ -33,13 +33,23 @@
-
+ // Editing a Comment text field.
+// elseif ($form_id['#id'] == 'node-type-form' && $form['post']['op'] != 'Save content type') {
+// _maxlength_content_type_form_alter($form, $form_state, $form_id);
+// }
I miss settings for comments. I will test the patch tonight.
This review is powered by Dreditor.
#2
oh this should be .
#3
Thanks for the patch. It seems to work fine. The only thing I would add is that I had expected the "comment limit length" options in the edit content type page to be in the "comment settings" form, rather than in the "submission form settings" form, which only has details for the title and body. Also, in its current location it sits between the "limit body length" and "minimum number of words" form fields. This is confusing because it makes it look as though the "minimum number of words" field applies to comments rather than the body.
#4
I changed the position of the "comment limit length" option to the comment form. I haven't made a patch before, and I've looked at it and I'm not sure it is correct, so I'll explain here too. The change I made to dereine's version is tiny, inside the foreach of _maxlength_content_type_form_alter(), I added:
<?php$parent_form = ($label == 'comment') ? 'comment' : 'submission';
?>
And I then changed the form variables from:
<?php$form['submission']
?>
to:
<?php$form[$parent_form]
?>
#5
Thanks for the patch
#6
#4 works for me
#7
are you moving this patch to 6.x-2.x HEAD?
#8
#4 Patch applies cleanly and works as advertised.
However for completeness, i would like to see it applied to the subject as well as the body of the comment before committing.
#9
i spoke to soon, it looks like this patch is set only to work for one content type :
+ if ($form['form_id']['#id'] =='edit-post-node-form') {Where 'post' is the content type.
Needs work.
#10
any news about this patch?
#11
I'm still planning to take a look at this, but I just have too much work on at the moment, I expect to look at it within 1-2 weeks, but others are welcome to jump in in the mean time.
#12
I can help as beta tester. Have a live site with this patch implemented.
#13
And, does the patch works fine?
#14
yes, but read all thread...
#15
Patch in #4 works fine for me, thank you!
#16
Right, I have gone over the comment functionality, and created a new version of maxlength.module which corrects the multitude of errors with the version posted above. The problems were:
* No validation was provided on comment body if javascript was not used
* Maxlength could not be applied to the comment subject
* The countdowns for the node title and body no longer appeared
These are all fixed in the given patch. In making these changes, I have changed quite a bit of code, so I hope this doesn't conflict with any other changes that have been made on this code in the mean time!
Hope people find it useful,
#17
Thanks Nicks, looks good from a first glance, i will see if i can make time today / tomorrow to get it committed !
#18
Exactly what I needed. Thanks!
#19
Subscribing. Thanks
#20
@nicks - can you confirm you patched against 6.x-2.x-dev ? I just tried to apply the patch and it missed on every chunk.
#21
Oh dear, I did the work on 6.x-2.0-beta1, so perhaps it's not so useful...!? It's the first proper patch I've submitted, so I guess that's a learning point to switch to the dev branch before you try doing anything significant...
I am pretty busy for the next couple of weeks, so won't get to look at the differences between the two versions for a while.
#22
Changing back to 6.x-2.x-dev - since that is where this needs to be committed
#23
Not to worry, soon as you can, i will review and commit.
#24
#16 maxlengthcomments.patch
The countdowns for comment not work
#25
Still a feature request... Changing to NR since we have a patch in #16 to try out.
Updated:
@nicks: would you provide another patch with your progress? I can't apply the one in #16, it seems to be invalid and looks kinda fuzzy...
#26
Subscribing. patch #16 is missing the filenames (can't find file to patch at input line 1)
#27
Hi. Sorry for the silence. I plan to look at making a 6.x-2.x-dev patch for this now I have a bit more time. I'm not sure what happened with my previous patch, but I've at least re-created a patch for the 6.x-2.x-beta1 version. Hopefully this one will work for people!
Nick
#28
So it looks like my changes apply to 6.x-2.x-dev without any problem at all, so here's another patch:
#29
patch #27 applies and works nicely on 6.x-2.0-beta1. Thank you!
#30
#28 failed on my latest maxlength dev. Thanks
#31
I just tested the patch on the Jan-18-2010 version of 6.x-2.x-dev which I downloaded from the project page and it worked fine for me. Can you confirm that this is the same version you tried to apply the patch to? Or give me any other info that would help me work out why the patch is failing?
#32
I used wysiwyg with tinymce and garland.
The configurations appear okay in the content type page, but the counter doesn't show up in the comment form. Do you think tinymce may interfere? But I had already install the compatibility plugin for tinymce as I found here somewhere and works fine in the node form, but not comment form. The good thing is if I place a larger amount of text than the preset, they are truncated to the limit.
Still digging around though, as I applied the patch manually :)
Thanks
UPDATE: I did some tweaks to the form, my mistake, it appears now, but still frozen. Not counting yet.
#33
So the problem is tinymce. When I disabled the editor, the counter starts working. Any idea to fix it?
I guess this part needs more work:
/**
* Gets executed when a TinyMCE editor instance is initialized.
*
* @param {TinyMCE_Control} Initialized TinyMCE editor control instance.
*/
init : function(ed, url) {
ed.onKeyDown.addToTop(this.handler);
},
handler : function(e) {
txt = tinyMCE.activeEditor.getContent()
element = e.id;
for (var id in Drupal.settings.maxlength) {
if (id == element) {
var limit = Drupal.settings.maxlength[id];
// calculate the remaining count of chars
var remainingCnt = limit - txt.length;
// update the remaing chars text
$('#maxlength-'+element.substr(5) + ' span.maxlength-counter-remaining').html(remainingCnt.toString());
}
}
}
Thanks
#34
I reported the problem in the plugin page => http://drupal.org/node/314508 to be more specific to the issue. Thanks
#35
UPDATE: Again this was my mistake. So sorry, hope this won't happen again. I forgot to check the compat mode with the comment filter. So both actually works from the beginning. Marking this SOLVED for my case. Hope this can be included in the next package.
Can I mark this reviewed and tested by community? This should be the very first time in my three years of membership here in drupal to do this :) But feel free to change it to something else if anyone minds.
Thanks
#36
Some codestyle :)
+ switch ($op)+ {
+ foreach ($labels as $label => $options) {+ $parent_form = $options['parent_form'];
+ $weight = $options['weight'];
+
+ if ($parent_form == 'submission')
+ {
tabs and wrong identation.
#37
Here's a patch with the code style updates. I couldn't see any other style issues, but that may just be because I am not completely au fait with drupal style guidelines, so feel free to point them out if I've missed any.
#38
Update status
#39
subscribe
#40
Can this be committed as an independent module? so many patches, suggestions, comments....confusion. A module or a final update will be appreciated.
#41
Vako, it makes no sense as an additional module.
The patch is "needing review", please do so and confirm it works if you want to see it included in the module.
#42
oh I see, this is part of the Maxlength module. OK, I will test it.
Just for curiosity, have you seen the module Facebook Status at http://drupal.org/project/facebook_status
It has a very nice countdown option to set the limit of the text entered.
#43
subscribe
#44
subscribe
#45
I tried the patch in #27 but I keep getting this:
patching file maxlength.module
patch unexpectedly ends in middle of line
patch: **** malformed patch at line 189:
What am I doing wrong?
#46
what the status of this patch
is it in dev or.. ?
#47
subscribe
#48
Commited #984794: Create API for non-node forms and used your patch to implement the feature
It worked fine for me, so feel free to try it out now.
This has to be ported to d7.
#49
Update status.
#50
After reading all these posts I realize that this is (now) about 7.x version.
But the 6.x version won´t work in my case.
All limiting options appear except the ones related to comments.
I have the 2.0-beta2 version installed.
How can I make it work? The readme file doesn´t explain about how to limit comment´s length.
Thanks for your help!
Rosamunda
#51
Any thoughts?
#52
7.x-3.x allows you to set the counter on any field, including the comment body.
Marking as won't fix.
#53
Hi again,
Why is this marked as won´t fix? I mean those patches won´t work... ever?
Is there any way to limit character count inside comments, in 6.x?
Thanks again!
#54
I'm not the maintainer of branch 6.x, but I thought for comment #48 that it had been commited.
As for branch 7.x-2.x it is not under development anymore. Branch 7.x-3.x has the functionality, hence marked as won't fix for branch 7.x-2.x.
If version 6.x-2.x still doesn't have the functionality, please feel free to re-open the ticket, but please make sure to specify why you are re-opening it.
#55
Thanks for your reply. But where´s the UI? I´ve looked for a limit under admin/content/node-type, and did find "limit body length" and "limit title length", but nothing about limiting comments length...
#56
i've just tried the latest Dev version ( October 23, 2011) everything is there. Under your Content Type>Comment Settings, there should be "Comment_comment max length" input field.
Works great!
#57
You´re rigth! THANKS! I didn´t tried the "dev" version!
#58
yes you should use the 3.x version instead of the 2.x.
The 2.x was just a small and fast port to D7, where 3.x is a rebuild of the functionalities.
There is a 2.x to 3.x upgradepath.