1

I have forked Joomla's feed display module (mod_feed) for my needs. It was working well until I have updated my site from 3.3.6 to 3.4.1.

I have news source which I have displayed on my Joomla site. RSS feed is as the following:

<channel>
    <title>Zkanoca</title>
    <atom:link href="http://example.com/?feed=rss2" rel="self" type="application/rss+xml" />
    <link>http://example.com</link>
    <description>Zkanoca loves you</description>
    <lastBuildDate>Fri, 27 Mar 2015 06:02:13 +0000</lastBuildDate>
    <language>tr-TR</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <generator>http://wordpress.org/?v=4.1</generator>
    <item>
        <title>My news title 1</title>
        <link>http://example.com/?p=142862</link>
        <comments>http://example.com/?p=142862#comments</comments>
        <pubDate>Thu, 26 Mar 2015 11:43:56 +0000</pubDate>
        <dc:creator><![CDATA[Zkanoca]]></dc:creator>
        <category><![CDATA[News]]></category>
        <category><![CDATA[General]]></category>
        <guid isPermaLink="false">http://example.com/?p=142862</guid>
        <description><![CDATA[Some text is here]]></description>
        <content:encoded><![CDATA[<p>Some text is here</p>
        <a href='http://example.com/?attachment_id=142863'><img width="150" height="150" src="http://example.com/wp-content/uploads/2015/03/0124-150x150.jpg" class="attachment-thumbnail" alt="01" /></a>
        <a href='http://example.com/?attachment_id=142864'><img width="150" height="150" src="http://example.com/wp-content/uploads/2015/03/0224-150x150.jpg" class="attachment-thumbnail" alt="02" /></a>]]></content:encoded>
        <wfw:commentRss>http://example.com/?feed=rss2&#038;p=142862</wfw:commentRss>
        <slash:comments>0</slash:comments>
        <picture>http://example.com/wp-content/uploads/2015/03/0124.jpg</picture>   
    </item>
    .
    .
    .
</channel>

Actually,

<picture>http://example.com/wp-content/uploads/2015/03/0124.jpg</picture>

part was not in original feed XML. I have added it with a little hack on Wordpress.

I have changed Joomla's mod_feed module in order to have a sliding news module, utilizing Bootstrap's carousel component.

It was properly working. But after I have updated the web site <picture> node comes empty so the carousel is unable to display the news' picture.

I have tried to search what has been changed from Joomla API directory. But could not find a clue.

I am trying to display the image using that line:

<img src="<?php echo $feed[$i]->picture; ?>" alt="<?php echo $feed[$i]->title; ?>" />

and it outputs as

<img src="/" alt="My news title 1" />

Before updating it used to show the picture properly. My carousel code is as the following:

<div class="carousel-inner">
    <?php
        $active = 'active';
        for ($i = 0; $i < $params->get('rssitems', 5); $i++) :
            if (!$feed->offsetExists($i)) {break;}
            $uri = (!empty($feed[$i]->uri) || !is_null($feed[$i]->uri)) ? $feed[$i]->uri : $feed[$i]->guid;
            $uri = substr($uri, 0, 4) != 'http' ? $params->get('rsslink') : $uri; ?>
            <div class="item <?php echo $active; ?>">
                <img src="<?php echo $feed[$i]->picture; ?>" alt="<?php echo $feed[$i]->title; ?>" />
                <div class="container">
                    <div class="carousel-caption">
                        <h2><a href="<?php echo $feed[$i]->uri; ?>" target="_blank"><?php echo $feed[$i]->title; ?></a></h2>
                    </div>
                </div>
            </div>
        <?php 
             $active = ''; 
              endfor; 
        ?>
0

After a deep investigation, I have found that I had modified libraries/joomla/feed/feed.php adding picture key to the $properties array:

    protected $properties = array(
    'uri' => '',
    'title' => '',
    'updatedDate' => '',
    'description' => '',
    'categories' => array(),
    'contributors' => array(),
    'picture' => '' //this line
);

I have also found that I had changed libraries/joomla/feed/parser/rss.php Added keys respectively where needed. For example:

//line 112
protected function handlePicture(JFeed $feed, SimpleXMLElement $el) {
    $feed->picture = (string) $el;
}

...


//line 355
    protected function processFeedEntry(JFeedEntry $entry, SimpleXMLElement $el) {
    $entry->uri = (string) $el->link;
    $entry->title = (string) $el->title;
    $entry->publishedDate = (string) $el->pubDate;
    $entry->updatedDate = (string) $el->pubDate;
    $entry->content = (string) $el->description;
    $entry->guid = (string) $el->guid;
    $entry->comments = (string) $el->comments;
    $entry->picture = (string) $el->picture;

After modifying current version's files according to previous version's it works now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.