Topic: [HACK] Automatic Short Story
Name: Automatic Short Story
Author: StealthEye
Updated by: FUNimations
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: This hack will allow you when adding news to add only the Full story and the Short story to be auto-generated from the first X characters of the full story.
Now you can use [truncate=X]...[/truncate] in your templates.
[truncate=10]1234567890[/truncate] -> 1234567890
[truncate=10]12345678901[/truncate] -> 1234567...
[truncate=10]12345678901234567890[/truncate] -> 1234567...
You should be able to do the same on a title, like
[truncate=20]{title}[/truncate]
if the title is longer than 20 chars, it will be truncated
Instructions:
Find this snippet of code in shows.inc.php 2 times:
$output = str_replace("{cute-http-path}", $config_http_script_dir, $output);
and below both, put this:
// Truncate v1.0 - addblock
if (!function_exists(clbTruncate)) {
function clbTruncate($match) {
if (strlen($match[2]) > $match[1]) {
return substr($match[2], 0, $match[1] - 3) . '...';
} else {
return $match[2];
}
}
}
$output = preg_replace_callback('#\[truncate=(.*?)\](.*?)\[/truncate\]#i', clbTruncate, $output);
// Truncate v1.0 - End addblock
*Update by FUNimations
CuteNews doesn't allow empty short stories. This error was reported with CN 1.4.6, older versions may also have this problem
In addnews.mdu find
if(trim($short_story) == "" or !$short_story){ msg("error","Error !!!","The story can not be blank.", "java script:history.go(-1)"); }
and put
//
in front of it.