Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Making RSS filter out HTML

 
Reply to topic    Forum Index » Help View previous topic
View next topic
Making RSS filter out HTML
Author Message
Thrik



Joined: 26 Oct 2005
Posts: 50

Post Making RSS filter out HTML Reply with quote
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. Sad
Wed Nov 30, 2005 9:04 pm View user's profile Send private message
Guest








Please login to hide the ads.

FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2801
Location: Germany

Post Reply with quote
What about something like this:

$string = str_replace("<yourspan>", "", $string);



What did you try?
Thu Dec 01, 2005 12:17 am View user's profile Send private message
Thrik



Joined: 26 Oct 2005
Posts: 50

Post Reply with quote
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 View user's profile Send private message
Thrik



Joined: 26 Oct 2005
Posts: 50

Post Reply with quote
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. Sad
Mon Jan 02, 2006 8:22 pm View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2801
Location: Germany

Post Reply with quote
You could make a new {rss-title} tag for your rss template.



Open inc/show.news.php and find this:

Code:
      $output = str_replace('{id}', $row['id'], $output);

      $output = str_replace('{title}', run_filters('news-entry-content', $row['title']), $output);




add above something like this:

Code:
      $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 View user's profile Send private message
Thrik



Joined: 26 Oct 2005
Posts: 50

Post Reply with quote
Omg, thanks. Smile



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 View user's profile Send private message
Display posts from previous:    
Reply to topic    Forum Index » Help All times are GMT + 1 Hour
Page 1 of 1

 
Jump to: 
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



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.