1 (edited by 2010-05-29 15:14:50)

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.

2 (edited by 2009-02-10 20:40:01)

Re: [HACK] Automatic Short Story

Name: Automatic Short Story - RSS fix
Author: DarkDragonLord
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: I had an issue where i used this hack and the RSS not showed anything as text, only the title/date of post. I spent 2hours to figure out that so others might have some question as that.
Requirements: The above hack.
Instructions:
Go to RSS template and in Active News, change this:

<description><![CDATA[{short-story}]]></description>


to this

<description><![CDATA[{full-story}]]></description>


If you want to be cooler and make something like the news you normally show at website with the truncate, put like this
(RSS Link Bug already fixed there)

<item>
<title><![CDATA[{title}]]></title>
<link>{rss-news-include-url}?subaction=showfull&id={news-id}&ucat={category-id}&archive={archive-id}</link>
<description><![CDATA[[truncate=200]{full-story}[/truncate]
<a href="{rss-news-include-url}?subaction=showfull&id={news-id}&ucat={category-id}&archive={archive-id}" style="font-size:0.7em;">Read More [+]<a/>]]></description>
<guid isPermaLink="false">{news-id}</guid>
<pubDate>{date}</pubDate>
</item>

See ya o/