• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.1 Stripping html from RSS title feed

steven s

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

http://xenforo.com/community/threads/way-to-remove-html-from-custom-titles.24379/
http://xenforo.com/community/thread...content-of-feeder-application-in-admin.11128/
http://xenforo.com/community/threads/trim-and-bbcode.15374/

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
#2
The cleanest solution would be to create an addon that extends the feed model:

XenForo_Model_Feed::prepareFeedEntry

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
#3
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.

Thanks.
 

steven s

Well-known member
#4
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?


PHP:
<?php
$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);
$count=mysql_num_rows($result);
 
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);
$count=mysql_num_rows($result);
 
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 />';