XF 2.2 How to use RSS feed summary

antzcode

New member
We are importing a podcast feed from Feedburner.

Each item has a summary that describes the podcast. We want to display the <itunes:summary>...</itunes:summary> content to the members so they can decide whether they might find the podcast interesting.

XML:
<item>
            <title>Teaching Boys to Respect Women</title>
            <itunes:subtitle />
            <itunes:author>Guest: Dave Willis</itunes:author>
            <itunes:summary>In a discussion based on his book "Raising Boys Who Respect Girls," Dave Willis offers parents advice for cultivating within their young sons a healthy respect for others, particularly girls and women.

Get Dave's book for your donation of any amount: https://store.focusonthefamily.com/singleitem/checkout/donation/item/don-daily-broadcast-product-2020-10-28

Get more episode resources: https://www.focusonthefamily.com/episodes/broadcast/teaching-boys-to-respect-women/

If you've listened to any of our podcasts, please give us your feedback: https://focusonthefamily.com/podcastsurvey/</itunes:summary>
            <pubDate>Wed, 28 Oct 2020 10:00:00 +0000</pubDate>

           
            <itunes:duration>1623</itunes:duration>
            <itunes:image href="https://images.subsplash.com/base64/L2ltYWdlLmpwZz9pZD1kYjMyYzY1Ny1iZTU3LTQ3YzEtYmRjOC02NDE2YTYxMzAwNzcmdz0xNDAwJmg9MTQwMA.jpg" />
            <itunes:order>2</itunes:order>
            <guid isPermaLink="false">a78b265a39b584edc1ab0dba83c55c5b</guid>
            <itunes:explicit>no</itunes:explicit>
        <enclosure url="http://feedproxy.google.com/~r/FocusOnTheFamilyDailyBroadcast/~5/2uAs6R-LfQo/audio.mp3" length="0" type="audio/mp3" /><feedburner:origEnclosureLink>https://dts.podtrac.com/redirect.mp3/focusonthefamily.mc.tritondigital.com/FOTF_BROADCAST_P/media/e56f2401-2081-465f-83d4-2585a5ea7adb/audio.mp3</feedburner:origEnclosureLink></item>

        <item>

At present, XF\Service\Feed\Reader::getEntries() handles the logic to populate template variables, making available {content} and {enclosure_url}. We then configure the Message Template in Admin Panel > RSS feed importer as follows:

Rich (BB code):
[music]{enclosure_url}[/music]

{content}

(Notice the cusom BB code music tag according to instructions here).

Now, the problem is that the content from <itunes:summary /> is not appearing in the {content} variable. I have found the reason for this:

XF\Service\Feed\Reader::getEntries() calls upon \Laminas\Feed\Reader\Feed\RSS::getContent() with a fallback to \Laminas\Feed\Reader\Feed\RSS::getDescription() in case of an Exception.

I have found that I can patch \Laminas\Feed\Reader\Entry\RSS::getContent() with a single line of code that will call upon the Laminas Extension: Laminas\Feed\Reader\Extension\Podcast\Entry::getSummary():

PHP:
// file: /src/vendor/laminas/laminas-feed/src/Reader/Entry/Rss.php
// line: 136 at 20201005

    /**
     * Get the entry content
     *
     * @return string
     */
    public function getContent()
    {
        if (array_key_exists('content', $this->data)) {
            return $this->data['content'];
        }

        $content = $this->getExtension('Content')->getContent();

        if (! $content) {
            $content = $this->getDescription();
        }

        if (empty($content)) {
            $content = $this->getExtension('Atom')->getContent();
        }
       
        // begin antz 20201005 - implement iTunes podcast in RSS feed importer
        if (empty($content)) {
            $content = nl2br($this->getExtension('Podcast')->getSummary());
        }
        // end antz 20201005 - implement iTunes podcast in RSS feed importer

        $this->data['content'] = $content;

        return $this->data['content'];
    }

That is a good, easy solution and it gives us exactly what we want:

focus-on-the-family-rss-feed-entry-20201030.png

Only problem is that because we are patching a Third-Party resource, there is a potential that the patch may be overwritten when performing upgrades. It also generates a big spooky error message that all Staff are seeing every time they visit the Admin Panel. So it has been reported to me and I have been advised to consult the community here for advice.

I can think of four options:

  1. Suppress the error message and create a task in the workflow to ensure that the patch remains applied after each upgrade.
  2. Request that Zend apply the patch to the Laminas framework in order to propagate the patch to future releases.
  3. Alter the XF core to make use of the Podcast Extension getSummary(), and then request that Xenforo apply the patch to the core.
  4. Write a custom extension for Xenforo that somehow does all this.

I'm inclined towards option 2, but I also reckon it's probably not likely to succeed, since the codebase appears to have deliberately omitted the feature. It also seems semantically incorrect to name summary as content, especially where there is a potential for both summary and content to be present in an RSS feed.

Options 3 and 4 seem too bloated, and option 1 is basically what I would do if it was my website, therefore it is not a thing I can do to someone else's website if there is a better option.

Thanks for your advice!
 
Last edited:
I have just created a thread on Laminas forums to discuss this with them:

 
4 is the recommended approach.

Personally though I would just go with the file edit and advise any admins to ignore the error related to that file.
The edit would have to be reapplied after each upgrade though.
 
4 is the recommended approach.

Personally though I would just go with the file edit and advise any admins to ignore the error related to that file.
The edit would have to be reapplied after each upgrade though.
I found a solution at the Laminas forums that seems pretty tidy and it seems like a thing that should be found naturally in XF core:

PHP:
// XF\Service\Feed\Reader::getFeedEntries() at line 135:
    $entryData = [
                    'id' => $entry->getId(),
                    'title' => html_entity_decode($entry->getTitle(), ENT_COMPAT, 'utf-8'),
                    'description' => html_entity_decode($entry->getDescription(), ENT_COMPAT, 'utf-8'),
                    'date_modified' => $dateModified,
                    'author' => $this->getAuthorsAsString($entry->getAuthors()),
                    'link' => $entry->getLink(),
                    // begin patch antz 20201102 - make podcast summary content available in RSS feed imports
                    'summary' => $this->getContent(nl2br($entry->getSummary())),
                    // end patch antz 20201102 - make podcast summary content available in RSS feed imports
                    'content' => $this->getContent($content)
                ];

Is there a way to ask the XF developers to add this feature to the code?
 
Thanks, here is the link:

 
Top Bottom