Jump to content

Recommended Posts

Posted

Hi there,

From the beginning, I always see a tiny glitch when browsing downloads or articles list. When the text of these items is very long, the "$file->truncated()" function seems that is not working very well, and loads the raw text (without HTML tags) and then, the frontend does the truncation.

What happens is that there is usually a glitch: while all the content is loading, until the "on.load" event, the text loaded is VERY long and eventually, this "onload" is fired and it is truncated.

In addition, this makes the site to download a very big HTML that afterwards is cut.

We could optimize this load, using a real truncation function.

I always change that function to sth like this:

<div class='ipsType_richText ipsType_break ipsMargin_bottom:half' data-ipsTruncate data-ipsTruncate-type="remove" data-ipsTruncate-size="2 lines">
  {{$num_char_total=strlen($file->truncated());}}
  {{$real_truncated_text=($num_char_total<400)?$file->truncated():substr($file->truncated(),0,strpos($file->truncated(), ' ', min(400,$num_char_total)));//el strpos es un truco para ir por palabras, cogemos la posicion del primer espacio tras 400 caracteres}}
  {$real_truncated_text|raw}
</div>

As you can see, I always try to cut the original raw text to 400 chars (avoiding to cut a word in the middle).

Do you think this would be a good idea to have it as standard?

Cheers,

Ibai

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...