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

XF 1.4 News Feed Max Snippet Length Being Ignored

Discussion in 'Troubleshooting and Problems' started by allbuffs, Aug 18, 2015.

  1. allbuffs

    allbuffs Member

  2. Sheldon

    Sheldon Well-Known Member

    I think you are looking for RSS Feed.

    News Feed is your site, your users.
     
  3. Sheldon

    Sheldon Well-Known Member

  4. allbuffs

    allbuffs Member

    You are correct. I was looking in wrong place. I did setup the feed. Is there a way to limit size of {content}
     
  5. Sheldon

    Sheldon Well-Known Member

    Quoting Mike... I figured that was next Q, so I searched it.

    That was a while back, but not sure it has changed or the option added.
     
  6. allbuffs

    allbuffs Member

    Cool. Thanks.
     
    Sheldon likes this.
  7. EQnoble

    EQnoble Well-Known Member

    Not that modifying core xf files is advisable, but if you want to implement this now yourself in the mean time, you can copy the original and save it for good measure and then go on to the following if you are comfortable tweaking php files yourself (which will get over written when an xf update rewrites that file)

    Edit: /library/XenForo/Model/Feed.php

    (@ around line 216)

    Find:

    PHP:
                $enclosure $entry->getEnclosure();
                if (
    $enclosure)
                {
                    
    $entryData['enclosure_url'] = $enclosure->url;
                    
    $entryData['enclosure_length'] = $enclosure->length;
                    
    $entryData['enclosure_type'] = $enclosure->type;
                }
    directly following that add this: (change 140 to the character limit you desire)

    PHP:
                if (utf8_strlen($entryData['content_html']) > 140) {
                    
    $entryData['content_html'] = substr($entryData['content_html'], 0140)) . '...';
                }

    so it looks like this:

    PHP:
                $enclosure $entry->getEnclosure();
                if (
    $enclosure)
                {
                    
    $entryData['enclosure_url'] = $enclosure->url;
                    
    $entryData['enclosure_length'] = $enclosure->length;
                    
    $entryData['enclosure_type'] = $enclosure->type;
                }
                if (
    utf8_strlen($entryData['content_html']) > 140) {
                    
    $entryData['content_html'] = substr($entryData['content_html'], 0140)) . '...';
                }

    *as a note this wont effect threads already created by the feeder
     
    allbuffs likes this.
  8. allbuffs

    allbuffs Member

    Thanks. Was just looking in Feed.php. I couldn't find the best place to do the substr. Glad I checked this thread again.
     

Share This Page