Keyword

Modify K2 RSS/Feed Output (add extra fields)

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
2 years 3 months ago #150904 by Joe Campbell
Joe Campbell created the topic: Modify K2 RSS/Feed Output (add extra fields)
How do I modify the K2 feed output?

Specifically, I would like to add Extra Field content to my feeds.

For example:

<title>This is the Item Title - Extra Field 17 Content Here</title>

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago - 2 years 3 months ago #150938 by Krikor
Krikor replied the topic: Modify K2 RSS/Feed Output (add extra fields)
I do not think this is possible.
If you plan to use it in an app or App Generator, I would recommend that you used JSON feeds instead.

You can hack the /components/com_k2/viewsview.feed.php file and try to replace the feed item's title.

The title is generated in line 218.
            $item->title = $this->escape($item->title);
            $item->title = html_entity_decode($item->title);
Use this code as a starting point. Remember to change the array's key to match your own site's setup.
            $fields = json_decode($item->extra_fields);
            $item->title = $this->escape($item->title);
            if ($fields[0]->value && $fields[0]->value !== '')
            {
                $item->title = html_entity_decode($item->title.' - '.$fields[0]->value);
            } 
            else 
            {
                $item->title = html_entity_decode($item->title);
            }

I tested this on a local site but not thoroughly. It seems to work fine.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/
Last Edit: 2 years 3 months ago by Krikor.

Please Log in or Create an account to join the conversation.

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
2 years 3 months ago #150963 by Joe Campbell
Joe Campbell replied the topic: Modify K2 RSS/Feed Output (add extra fields)
Thanks @Krikor :)

I am a little confused by your solution. I will further discuss it with you upon showing you my site (very soon).

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #150979 by Krikor
Krikor replied the topic: Modify K2 RSS/Feed Output (add extra fields)
It's a hack, so it's best to decide if you really need before actually performing it.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

Please Log in or Create an account to join the conversation.

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
2 years 3 months ago #150992 by Joe Campbell
Joe Campbell replied the topic: Modify K2 RSS/Feed Output (add extra fields)
You're right @Krikor.

I figured out a way to accomplish the task with the help of NoNumber ReReplacer (my favorite Joomla extension other than K2)

It requires me making an rule for each RSS feed. It's time consuming, but non-destructive :)

But there's more, for categories with different content types. I am going to use MailChimp's ChimpFeedr ( chimpfeedr.com ) to merge those feeds into one.

The real lesson is "Granular control comes at a cost. It's called time." I just made the quote up :-)

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #151017 by Krikor
Krikor replied the topic: Modify K2 RSS/Feed Output (add extra fields)
Haha :) nice quote.
Thanks for chimpfeedr.com/ I was not aware of that service.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago #166594 by linox
linox replied the topic: Modify K2 RSS/Feed Output (add extra fields)
Hello, I need your solution using the replacement, could you tell me how you did to make the extra fields of the page appear in the feeds, I need an output in json for an application, this solution is very important for me and I would like Thank you, thank you. I'm from Brazil.

Please Log in or Create an account to join the conversation.

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
3 months 1 week ago #166595 by Joe Campbell
Joe Campbell replied the topic: Modify K2 RSS/Feed Output (add extra fields)

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago #166660 by Krikor
Krikor replied the topic: Modify K2 RSS/Feed Output (add extra fields)
Thanks Joe :)

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

Please Log in or Create an account to join the conversation.

Moderators: william white