Subject: To create a words length limit

Posted on: 16/05/18 08:44am
By: OMAL

I would like to limit the length of intro text, if possible (and I know it's possible but it would be quite complicated in case of customization).

If anyone know the way or plugins doing like that, let me know.

The important point is that how to deal with the html source between tags or inside a tag. For instance, when the break point is <img src="ho (here would be the break point) ge" alt ="hoge">, image is not displayed.

Thanks.

Re: To create a words length limit

Posted on: 16/05/18 06:11pm
By: OMAL

I've resolved this issue by myself.
But any information about plugins would be appreciated.

Re: To create a words length limit

Posted on: 17/05/18 06:56am
By: Laugh

What was your solution?

There are no plugins that allow limiting of the article editor intro section. That would have to be built into the article editor itself.

The other option is to use the advanced editor and then force it to limit the characters:

https://stackoverflow.com/questions/34473418/ckeditor-limit-characters-on-more-editors-in-one-page

This would require some changes with Geeklog itself as well since you would only want this to happen for the intro area.

For a different solution you could also look at COM_truncateHTML which we use to truncate rss feeds in Geeklog. It will remove mangled html tags and add any missing close tags. Of course to use something like this the article editor would have to be customized.



Re: To create a words length limit

Posted on: 18/05/18 11:16am
By: OMAL

What was your solution?


I just added the following lines before DB_save in the story.php.

PHP Formatted Code
           $word_length= 470;
           $strlen_bf = mb_strlen($introtext,'utf-8');
            $introtext = mb_strimlen($introtext,0,$word_length,"...",'utf-8');
            $strlen_af = mb_strlen($introtext,'utf-8');
            if($strlen_bf <> $strlen_af){
                        $display .= COM_siteHeader('menu', $LANG24[5]);
                        $display .= COM_errorLog('Your intro text is too long to submit.', 2);
                        $display .= storyeditor($sid);
                        $display .= COM_siteFooter();
                        echo $display;
                        exit;
            }
 


You could define the word_length as $_CONF['word_length'] in custom config.file.

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=96746