• 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

Sheldon

Well-known member
#5
You are correct. I was looking in wrong place. I did setup the feed. Is there a way to limit size of {content}
Quoting Mike... I figured that was next Q, so I searched it.

That option controls your outgoing feeds.

The feed posting system will simply post what is in the RSS feed that you're reading from. There's no option on the XF end to limit the length of the feed content.
That was a while back, but not sure it has changed or the option added.
 

EQnoble

Well-known member
#7
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'], 0, 140)) . '...';
            }

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'], 0, 140)) . '...';
            }

*as a note this wont effect threads already created by the feeder