Skip to main content

How to filter the site Feed - blocking posts from one space

Hi. My automation of post updates is working great. I have about 20 posts with maps that get updated every hour. Fantastic! BUT... that word again... I have a new problem.

The feed for the site is swamped by these updating posts. I want to be able to stop these (all coming from one particular space) from showing up at the top of the feed - you never can see the other normal posts I make.

I think there is probably some filter way of doing this, but any help would be appreciated :)

Thanks,

Jamie

Jamie Robe

Hi everyone, I solved my own issue. I will share in case it helps others in the future:

What happens when a post is manually created or edited (or automatically updated like my map posts are), the database table that stores the posts has a field called updated_at that gets set to the current moment in time. This causes them to float up to the top of the community feed. Normally that is a good thing, but in my case, there are lots and lots of these posts that are updated hourly. So they swamped out all other posts in the feed.

To solve I added this code to my snippet. I inserted them right above the final save.

    // 3. Persist to database
    //// To keep the posts from having updated_at timestamps that push to top of main feed
      // Disable automatic timestamp updates for existing posts
      $feed->timestamps = false; 
      // Manually set updated_at to the original creation time
      // This prevents the post from jumping to the top of the activity feed
      $feed->updated_at = $feed->created_at;
    ////

      $feed->save();

This works. All the automated posts now will always have the updated_at date and time set back to the original creation date :)

I was looking for some sort of fluent filter that would take the feed (would be an array of all the posts in a feed) and I could then alter that array and pass back the changes. However, I was unable to figure out if such a command or hook exists at this stage of Fcom development. I filed a support ticket but honestly it was beyond what support would do.

Anyway, I am VERY happy again.

Peace,

Jamie