Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
Hi,

I'm trying to use the max_len validator in my posts. In the beginning I found it extremely useful, but then, during the tests, I found out that every time I try to change the font-size and the span tag is being added, it adds extra 37 characters to the final characters amount (which is actually quite logical, but...). Is there a chance to modify something so it will not count the characters added in tags? Entire content is a normal text only, so there is no chance any triangular brackets will be added in the content, if it helps. I will be grateful for any advice/solution.

Cheers,
S.

Edit: Figured it out, so sorry for spam. If anyone will ever be in a similar situation, you might find the function for your validator (validate_max_len in this case) and combine trim function with strip_tags.
Hi and welcome, pinks :)

I am glad you found a solution.
Obviously you have no problems working with PHP. Therefore I'd suggest that instead of directly modifying the core files of Couch (and risking overwriting your changes with version updates), you please create your own custom validator.

The process is pretty simple.
As you figured out, the original validator function is 'validate_max_len' in functions.php.
1. Copy this function into kfunctions.php file (either the one found in 'couch/addons' or create one of that name in your site's root).
2. Rename it to something of your choice (let us assume 'my_validate_max_len').
3. Modify its code to suit your requirements (strip_tags etc. in your case).
4. Your custom validator is now ready for use. Simply specify 'my_validate_max_len' as the value of the 'validator' parameter of your editable region.

Hope this helps.
2 posts Page 1 of 1
cron