1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can I add items to the recent activity stream programmatically

Discussion in 'XenForo Development Discussions' started by rhodes, Sep 30, 2014.

  1. rhodes

    rhodes Active Member

    Hello,

    I run a drupal database (system 2) in the background of my xf1.3 (system 1) delivering json and rss feeds.

    On some events of system 2 I would like to notify my forum users (system 1) via the recent activity stream.

    Is it possible to write into the activity stream from outside xf (maybe directly to the db)? I've already searched for an API supporting this functionality, but I could not find one. Maybe there is a xf function I could call after loading xf within system 2?

    Any ideas?

    Regards, rhodes
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Check out how the "NewsFeedHandler" system works in XF.

    I don't know how familiar you are with XF development, but News Feed and Recent Activity basically get the data from the same system. If you look at how it works for things like Likes, Profile Posts etc. then you should get a fair idea of how to implement it for your own content types.
     
  3. rhodes

    rhodes Active Member

    Thank you for this hint @Chris D . Unfortunately up to now I'm not too familiar with XF development. Basically I develop drupal cms systems. But the "NewsFeedHandler" system is a good point to start.
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Do you own Xen Media Gallery? (I think you do).

    Feel free to look how I implement Recent Activity / News Feed stuff there. Generally:
    • Content types and fields added to the xf_content_type and xf_content_type_fields tables in XenGallery/Install.php
    • The actual NewsFeedHandler code in the XenGallery/NewsFeedHandler/ directory
    • Search for references to "NewsFeed" in my files in the XenGallery/DataWriter directory (specifically where the publish function is called).
    That's generally it.

    After adding the content types, the content type caches need to be rebuilt. You can trigger a rebuild by installing/upgrading an add-on to do that, or delete the contentTypes key from the xf_data_registry table or directly call the function that rebuilds content types.
     

Share This Page