Shorten webSPELL Texts

You may come to the point where you find a really long text and you want to shorten it up.
E.g. your File-Categories-Overview - if you provide detailed Information for your Downloads the List can get pretty long. I'm showing you 3 ways to shorten Texts up. If you have any additional methods, let me know ;)
BBCode: toggle
You don't want to open any PHP or HTML-File? Just add the toggle-BBCode arround the Text that shouldn't be visible right away.This is the sentence everyone should read right away
[toggle=read more]This is hidden and can be seen (without page-reload) by clicking on "read more"[/toggle]
Result:

Shorten after a specific number of letters
This is pretty easy too and doesn't need any work afterwards, if you didn't use BBCode or HTML in the Texts you're about to shorten. As you just cut after, lets say 200 letters, it could otherwise happen that you opened BBCode- or HTML-Tags and you never closed them - you should look out for that!Lets shorten the output of the File-Categories-Overview-Description-Text.
First thing we need to know is what the variable is called.
Easiest way is to go into your templates-Folder and search for the right HTML-File, in our case its files_category_list.html here is it's content:
<tr>
<td bgcolor="$bg1">$filename</td>
<td bgcolor="$bg1">$fileinfo</td>
<td bgcolor="$bg1" align="center">$fileload</td>
<td bgcolor="$bg1">$ratingpic</td>
<td bgcolor="$bg1" align="center">$link</td>
</tr>
You guessed it, its $fileinfo. Now we need to edit files.php!
Search for:
$fileinfo
Add below (200 = number of letters that are shown):
if(mb_strlen($fileinfo)>200) {
$fileinfo=mb_substr($fileinfo, 0, 200);
$fileinfo.='...';
}
It can happen that you will finde a variable for several times in the same File. So what are you supposed to do?
a) You know what the code is saying and you can say eather it is the right spot or not.
b) You don't know if it is the right spot so you just past the Code blow the line you found the variable, save the file, upload it, test (if it wasn't the right spot - undo your change and start over again)
The "Read More"
You might know the Easy "Read More" for webSPELL, we could also use this to Shorten our File-Categories-Overview-Description-Text.So we are opening files.php and searching for the $fileinfo.
Add this below:
Code:
1. 2. | $foo=explode('[break]', $fileinfo); $fileinfo = $foo[0].'...'; |
Now you can add the BBCode
Code:
into your File-Description and it will be shorten.1. | [break] |
As we see in templates/files_display.html the variable that contains the File-Description is also called $fileinfo so we have to find the right spot again and add this below:
Code:
1. 2. | $foo=explode('[break]', $content); $content = $foo[0].''.$foo[1]; |
If we wouldn't do this the BBCode [break] would always show in the Description. Tweet

