Jump to content

Activity Stream, suggestions?


3fingers
 Share

Recommended Posts

Hello all,

I'm trying to figure out a method to build an activity stream in PW (or vanilla php).

Something like "User1 has updated his profile picture 10 minutes ago" "User2 added/modified his profile description" and so on...

Does anyone have some suggestion to point me in the right direction?

Thanks!

Link to comment
Share on other sites

How's this to get things rolling?

foreach($pages->find("id!=2, id!=7, has_parent!=2, has_parent!=7, template!=admin, sort=-modified") as $p){
   echo "<p>{$p->modifiedUser->name} updated {$p->title} " .  wireRelativeTimeStr($p->modified)."</p>";
}
  • Like 3
Link to comment
Share on other sites

This is a good starting point, for sure....what about setTrackChanges() method?

Never used before and it's kind of a mistery to me how its usage would be.

Do you think that would come in handy?

Link to comment
Share on other sites

I've implemented similar things before (not in PW, but still PHP/MySQL) and each item is its own entry.

From that experience, it's a lot easier to filter on, personalise and scale, if you have an explicit container of items with their own reference for type of update, user, timestamp and so on. This should let you easily control the wording of the updates, decide if an update should actually be added or ignore it (e.g. prevent too many of the same type within a short space of time), and easily build in comments/like functionality.

  • Like 1
Link to comment
Share on other sites

Here is a snippet that I have used to quickly determine changes of defined fields:

	public function getModifiedStamps($tablenames) {
		$tablenameDefaults = array('field_title', 'field_headline', 'field_somename');
		$tablenames = array_merge($tablenameDefaults, $tablenames);
		$stamps = array();
		foreach($tablenames as $tablename) {
			$r = wire('db')->query("SHOW TABLE STATUS LIKE '$tablename'");
			$row = $r->fetch_assoc();
			$stamps[$tablename] = strtotime($row['Update_time']);
			#$stamps['s_'.$tablename] = date('d.m.Y H:i:s', strtotime($row['Update_time']));
		}
  • Like 5
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...