0

I am trying to develop Bootstrap's carousel module for news which are fetched from a remote website using its RSS feed for my Joomla 3.3.3 web site. It is a WordPress web site. I have added the following code to WP web site's theme/functions.php

function zkanoca_add_image_to_rss() {
    $thumb_id = get_post_thumbnail_id( get_the_ID() );
    if ( ! empty( $thumb_id ) ) {
        echo '<myimage>' . wp_get_attachment_url( $thumb_id ) . '</myimage>';
    }
}
add_action('rss2_item', 'zkanoca_add_image_to_rss');
add_action('rss_item', 'zkanoca_add_image_to_rss');

I now can see <myimage>[image_url]</myimage> line in the rss feed when I look at the source code.

But I do not know how to handle it on Joomla's RSS feed module (mod_feed).

I have tried to extract image url using

 $feed[$i]->myimage;

in a loop just like $feed[$i]->title; but did not work.

I call var_dump() function for an item but could not see a key element for <myimage> information.

I have found /libraries/joomla/feed/parser/rss.php and then added

protected function handleMyimage(JFeed $feed, SimpleXMLElement $el) {
        $feed->myimage = (string) $el;
    }

After that, I have modified /libraries/joomla/feed/feed.php

// /libraries/joomla/feed/feed.php protected $properties = array( 'uri' => '', 'title' => '', 'updatedDate' => '', 'description' => '', 'categories' => array(), 'contributors' => array(), 'myimage' => '' //added this key );

Then I added

 // /libraries/joomla/feed/link.php line 60s
 public $myimage;

into JFeedLink class and modified

// /libraries/joomla/feed/link.php line 90s
public function __construct($uri = null, $relation = null, $type = null, $language = null, $title = null, $length = null ) {
        $this->uri = $uri;
        $this->relation = $relation;
        $this->type = $type;
        $this->language = $language;
        $this->title = $title;

        // Validate the length input.
        if (isset($length) && !is_numeric($length)) {
            throw new InvalidArgumentException('Length must be numeric.');
        }
        $this->length = (int) $length;
    }

to 

// /libraries/joomla/feed/link.php line 90s 
public function __construct($uri = null, $relation = null, $type = null, $language = null, $title = null, $length = null,  /* added this */ $myimage = null /**/) {
        $this->uri = $uri;
        $this->relation = $relation;
        $this->type = $type;
        $this->language = $language;
        $this->title = $title;
        $this->resim = $resim; //added this line too

        // Validate the length input.
        if (isset($length) && !is_numeric($length)) {
            throw new InvalidArgumentException('Length must be numeric.');
        }
        $this->length = (int) $length;
    }

in /libraries/joomla/feed/link.php

1

I was almost about to finish it with success :) I have forgotten to add just one line into /libraries/joomla/feed/parser/rss.php

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->myimage= (string) $el->myimage; //this line

Now, my problem has gone.

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.