How to display custom content types in xf_news_feed as Recent Activity (NewsFeed)?

marquisite

Well-known member
I've been searching around the Xenforo forums and can't find how to have Xenforo display a custom content type as a news feed item. Would anybody have any pointers or know of any good tutorials that will do this?

I already have got as far as having the custom news feed data inserted into the xf_news_feed using XenForo_Model_NewsFeed()->publish(), and I have a news_feed_item_[contenttype]_insert template as well. But I'm just not sure what to do next to have the custom content type show up as recent activity. All the data I need to display is contained within the extra_data column of xf_news_feed for a given news feed item.

Any pointers would be greatly appreciated! :)
 
Hi @Syndol 2.0 , yes I have but thanks for asking. The custom news feed items will sometimes show up but more often it won't. But if I print out the contents of the $ids array in the getContentByIds function for the custom news_feed_handler_class , it correctly spits out the news feed id(s) for all the missing item(s) for the custom contenttype.

Although I can't say this conclusively, It seems to not work whenever there are 2+ different users associated with separate instances of the same custom news feed contenttype. If there are multiple custom feed items associated to only me and nobody else for example, I can see them and so can other people. I've seen a custom news feed item associated with another user too (call them UserX) but looking at the xf_news_feed table at the time all of the custom news feed items were associated with UserX. Right at this moment there are multiple custom news feed items associated with three different users (myself and two others) but I can't see any of them in Recent Activity.
 
Last edited:
I've not had any success getting custom news feed items to consistently display in recent activity.
  • I've extended XenForo_NewsFeedHandler_Abstract with my own news_feed_handler_class
  • I've used @Chris D's Content Type Management addon to associate a new contenttype (let's call it video) with my own news_feed_handler_class and to rebuild the content types.
  • I have created a new template in the Master Style using the format news_feed_item_[contenttype]_[action], so news_feed_item_video_insert
Within the above custom news_feed_handler class, doing a print_r($ids) inside the getContentByIds function returns all of the news feed items ids for the video contenttype I'm attempting to display whether these events are associated to one or multiple users. Despite this, using return $ids in this function won't make the news items display.

So it seems something after getContentByIds() isn't handling the news items when items for this contenttype exist for more than one account, but does handle it providing that only one account is associated with news items of this custom contenttype.

What could be missing or incorrect that prevents the news items displaying for a particular custom contenttype when items exist for different accounts (but works if all items are for a single account only)?

EDIT: This post appears to have fixed my issue: https://xenforo.com/community/threa...ser-and-whats-content-type.96799/#post-928609 :D
 
Last edited:
Top Bottom