1. 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

Discussion in 'Troubleshooting and Problems' started by steven s, May 6, 2012.

  1. steven s

    steven s Well-Known Member

    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?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.
     
  3. steven s

    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.

    Thanks.
     
  4. steven s

    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?


    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 />';
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That can work. But I like my solution better (extend the feed model with an addon).
     
  6. steven s

    steven s Well-Known Member

    Easy for you to say.
    I can only work with the tools I have. :)
     

Share This Page