XF 1.1 Stripping html from RSS title feed

steven s

Well-known member
I've read through a couple threads.


All above my head.
I am starting a new forum and to get the ball rolling I am using an RSS feed.
Problem is that there is html markup in the titles.

I can't manually clean it up every day.
Is there a solution?
A cron job that ran after the rss import?

Jake Bunce

XenForo moderator
Staff member
The cleanest solution would be to create an addon that extends the feed model:


That would allow you to perform string operations on the title before it is written to the database.

You can also modify the code directly (library/XenForo/Model/Feed.php), but file changes are overwritten when you upgrade.

steven s

Well-known member
Seems to me that it's something that should be built it. :(
I'll see how far I get with the site then maybe offer some $$$ for someone to create an addon for me.


steven s

Well-known member
To strip html from thread titles and the latest post I modified Donnie's script.
Since I don't know what I'm doing, is this one method of accomplishing what I want?

I would prefer the username, passsword, host and database to use the data from xf's config file.
I'll probably create a cronjob and time it just after the rss feed is run or is there a better way without touching any core files?

$user = '';
$pass = '';
$host = '';
$db  = '';
$link = mysql_connect($host, $user, $pass);
if (!$link)
    die('Could not connect: ' . mysql_error());
mysql_select_db($db, $link);
/* strips html in title */
$query = ("SELECT * FROM xf_thread WHERE title LIKE '%<b>%'");
$result = mysql_query($query, $link);
while ($row = mysql_fetch_assoc($result)) {
    $id = $row['thread_id'];
    $new_title = strip_tags($row['title']);
    $new_query = "update xf_thread set title = '$new_title' where thread_id = $id";
    mysql_query($new_query, $link);
echo $count . ' thread titles done!<br />';
/* strips html from last post */
$query = ("SELECT * FROM xf_forum WHERE last_thread_title LIKE '%<b>%'");
$result = mysql_query($query, $link);
while ($row = mysql_fetch_assoc($result)) {
    $id = $row['node_id'];
    $new_title = strip_tags($row['last_thread_title']);
    $new_query = "update xf_forum set last_thread_title = '$new_title' where node_id = $id";
    mysql_query($new_query, $link);
echo $count . ' lastest thread done!<br />';