Help Center
Find answers or browse our knowledge base.
Latest Questions
post_to_feed
📰 Hook: post_to_feed
The post_to_feed
filter hook lets addons customize how posts appear in the Sngine newsfeed. It is triggered every time a feed post is prepared for rendering.
📌 Signature
apply_filters('post_to_feed', $value, $post);
- $value → array of fields passed to feed templates
- $post → raw feed post data from database
- Must return the modified
$value
📂 Template Dependencies
- Addonid/tabs/feed_story.tpl → renders the main storyline text (headline of the post)
- Addonid/tabs/feed_content.tpl → renders body, attachments, or any custom block your addon injects
That means if your addon injects $value['story']
, it will be displayed inside feed_story.tpl
. If your addon injects custom keys like $value['book_custom']
, they can be rendered in feed_content.tpl
.
✅ Example: Books Addon
Hook file: modules/books/hooks/post_to_feed.php
return function($value, $post) {
if ($post['post_type'] === 'book') {
// Storyline for feed_story.tpl
$value['story'] = $post['user_firstname'] . " is reading 📖";
// Extra block for feed_content.tpl
$value['book_custom'] = [
'title' => $post['book_title'],
'url' => $post['book_url']
];
}
return $value;
};
feed_story.tpl
{if $post.post_type == "book"}
Jane is reading {$post.story}{/if}
feed_content.tpl
{if isset($post.book_custom)}
🔎 How It Works
- Your addon’s hook modifies the
$value
array. - Sngine passes that array into the feed templates.
feed_story.tpl
shows the short text (headline).feed_content.tpl
shows extended details or attachments.
💡 Best Practices
- Always check
$post['post_type']
before modifying output. - Use
$value['story']
for human-readable text (the "Jane is reading a book" headline). - Use custom array keys for extra data (e.g.
book_custom
,badge_custom
). - Keep template logic minimal — put conditions and DB queries inside the hook, not in TPL.
Was this answer helpful?
You must login to vote.
0 found this helpful,
0 did not
How could it be better?
What went wrong?
Thank you for your feedback!