RedSocialStream Support for K2

joomla k2 redsocialstream social-media database php cms

Adding K2 content management system support to the RedSocialStream Joomla social media component

RedSocialStream and K2 Integration

RedSocialStream is an excellent Joomla! component for sharing posts to Facebook, Twitter, LinkedIn, and YouTube. However, it lacks native support for K2, Joomla’s powerful content management extension.

Since I use K2 to manage all my content, I needed RedSocialStream to work with K2 articles. This modification allows the component to post K2 content to social media platforms.

Important Disclaimer

These changes are specifically for outbound social media posting only. I haven’t tested (and don’t plan to use) other RedSocialStream features like inbound social media integration. Making these changes could potentially break untested features.

If you encounter issues after applying these modifications, we can work through debugging them together.

PHP Code Modifications

Open administrator/components/com_redsocialstream/models/postfeeds.php and make the following changes:

Change 1: _buildQuery() Function (Line 71)

Replace this:

$query = ' SELECT *  FROM #__content WHERE state=1';

With this:

$query = ' SELECT *  FROM #__k2_items WHERE published=1 and trash = 0';

Change 2: getArticleData() Function (Line 79)

Replace this:

$query = ' SELECT *  FROM #__content WHERE state=1 and id='.$article_id;

With this:

$query = ' SELECT *  FROM #__k2_items WHERE published=1 and id='.$article_id;

Key Differences

  • Joomla Content: Uses state=1 for published articles
  • K2 Items: Uses published=1 for published items and adds trash = 0 to exclude trashed content

Database Cleanup Required

After making these changes, you may notice that the RedSocialStream component incorrectly shows some K2 content as already posted when it hasn’t been.

To fix this, truncate the RedSocialStream post feeds table:

TRUNCATE TABLE #__redsocialstream_postfeeds;

Note: Replace #_ with your actual Joomla database table prefix if running this from the command line.

What This Enables

With these modifications, RedSocialStream can now:

  • ✅ Pull content from K2 items instead of Joomla articles
  • ✅ Post K2 articles to social media platforms
  • ✅ Maintain proper publishing status checks
  • ✅ Exclude trashed K2 items from posting

This integration allows you to leverage K2’s advanced content management features while still using RedSocialStream for social media distribution.