Hi everyone,
Sorry to bring up this topic again, but I am going out of my mind! I have one snippet call in my ditto rss template that works like a charm. But the next one is simply being printed out within the page and it’s driving me mad! It is obviously something I am doing but I cannot see what’s wrong. Could I get another set of eyes to look at the code?
My RSS template:
<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>My title</title>
<link>http://www.mysite.com/</link>
<description><![CDATA[Up-to-date information from My Site]]></description>
[*content*]
</channel>
</rss>
My ditto call in a text/xml content type:
[[Ditto? &startID=`98,100,52,51,70` format=`rss` &tpl=`rss_feed` &dateFormat=`%a, %d %b %Y %T %Z` &total=`20` &display=`20` &filter=`id,58,2|id,56,2|id,57,2|id,72,2`]]
My rss template:
<item>
<title>[!cdata? &txt=`[+pagetitle+]`!]</title>
<link>[(site_url)][~[+id+]~]</link>
<description>[!tiny? &txt=`[+content+]`!]</description>
<pubDate>[+date+]</pubDate>
<guid>[(site_url)][~[+id+]~]</guid>
</item>
The working snippet (cdata):
<?php
if($txt) {
$output = '<![CDATA[' . $txt . ']]>';
return($output);
}
?>
The non-working snippet(tiny):
<?php
if($txt) {
$tot_length = strlen($txt);
$numb = isset($numb)? $numb:100;
$numb = $tot_length < $numb? $tot_length : $numb;
$find = "[";
$position = stripos($txt, $find);
$trunc = $position > $numb? $numb: $position;
$output = "<![CDATA[ ";
$output .= substr($txt, 0, $trunc);
$output .= "...";
$output .="]]>";
return($output);
}else{
$output = "no description available";
return($output);
}
?>
This second snippet is meant to truncate the content dependant on whether modx tags are present or not. I need to do this because I want to exclude any maxigallery or other specialized content and just give a short preview of the content.
Thanks to anyone can spot my errors.
Sheri