Welcome to Geeklog Saturday, October 20 2018 @ 08:19 pm EDT

Geeklog Forums

To create a words length limit


Status: offline

OMAL

Forum User
Chatty
Registered: 06/12/17
Posts: 59
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.

Status: offline

OMAL

Forum User
Chatty
Registered: 06/12/17
Posts: 59
I've resolved this issue by myself.
But any information about plugins would be appreciated.

Status: offline

Laugh

Site Admin
Admin
Registered: 27/09/05
Posts: 1308
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.



One of the Geeklog Core Developers.

Status: offline

OMAL

Forum User
Chatty
Registered: 06/12/17
Posts: 59
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.

All times are EDT. The time is now 08:19 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content