 |
 |
 |
 |
 |
| Author |
Message |
Thrik
Joined: 26 Oct 2005 Posts: 50
|
|
Making RSS filter out HTML |
|
I've got a problem where as you can see on my site (teamkilled.net) I used a span tag in the titles to emphasise certain words. The problem is that these are getting carried over into the RSS feed and wrecking it for RSS clients which can't filter out HTML. So, can anyone help me with getting rid of the HTML for the titles when under RSS? I've tried a few methods myself but all have failed. 
|
|
| Wed Nov 30, 2005 9:04 pm |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2801 Location: Germany |
|
|
|
What about something like this:
$string = str_replace("<yourspan>", "", $string);
What did you try?
|
|
| Thu Dec 01, 2005 12:17 am |
|
 |
Thrik
Joined: 26 Oct 2005 Posts: 50
|
|
|
|
I attempted to use str_replace funnily enough, in rss.php. I basically tried to turn the show_news include into a variable and then echo it, but weirdly the PHP seemed to totally ignore it! Even though I didn't actually echo the variable afterwards, it still outputted everything anyway. If I then attempted to echo it using str_replace it would just echo at normal but add a '1' to the RSS output.
Really odd stuff. I can't understand it at all.
|
|
| Thu Dec 01, 2005 2:10 am |
|
 |
Thrik
Joined: 26 Oct 2005 Posts: 50
|
|
|
|
Hmm, still having trouble with this in 2.5. I've now tried to do a str_replace in the .tpl files and it just borks up. Really clueless as how to fix this. 
|
|
| Mon Jan 02, 2006 8:22 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2801 Location: Germany |
|
|
|
You could make a new {rss-title} tag for your rss template.
Open inc/show.news.php and find this:
 |  | $output = str_replace('{id}', $row['id'], $output);
$output = str_replace('{title}', run_filters('news-entry-content', $row['title']), $output); |
add above something like this:
 |  | $rss_title = str_replace("<htmlstuff>", "", $row['title']);
$rss_title = str_replace("<htmlstuff2>", "", $rss_title);
$output = str_replace('{rss-title}', run_filters('news-entry-content', $rss_title), $output); |
You can add more replacements in the same way as the second line of this code.
|
|
| Tue Jan 03, 2006 1:18 am |
|
 |
Thrik
Joined: 26 Oct 2005 Posts: 50
|
|
|
|
Omg, thanks.
It didn't work at first, but then I thought since I use quick tags for the emphasis html ([e][/e]), it might be reading those first.. turns out it is. I put [e] and [/e] in the str_replace instead and it works beautifully now.
<3
|
|
| Tue Jan 03, 2006 1:45 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|
 |
 |
 |
|