Keyword

Modify K2 RSS/Feed Output (add extra fields)

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
8 years 10 months ago #150904 by Joe Campbell
Modify K2 RSS/Feed Output (add extra fields) was created by Joe Campbell
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.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 10 months ago - 8 years 10 months ago #150938 by Krikor Boghossian
Replied by Krikor Boghossian on 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.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Last edit: 8 years 10 months ago by Krikor Boghossian.

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
8 years 9 months ago #150963 by Joe Campbell
Replied by Joe Campbell on 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.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 9 months ago #150979 by Krikor Boghossian
Replied by Krikor Boghossian on 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.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
8 years 9 months ago #150992 by Joe Campbell
Replied by Joe Campbell on 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.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 9 months ago #151017 by Krikor Boghossian
Replied by Krikor Boghossian on topic Modify K2 RSS/Feed Output (add extra fields)
Haha :) nice quote.
Thanks for chimpfeedr.com/ I was not aware of that service.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
6 years 9 months ago #166594 by linox
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
6 years 9 months ago #166595 by Joe Campbell

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 9 months ago #166660 by Krikor Boghossian
Replied by Krikor Boghossian on topic Modify K2 RSS/Feed Output (add extra fields)
Thanks Joe :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum