3fingers Posted May 23, 2014 Share Posted May 23, 2014 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 More sharing options...
adrian Posted May 23, 2014 Share Posted May 23, 2014 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>"; } 3 Link to comment Share on other sites More sharing options...
3fingers Posted May 23, 2014 Author Share Posted May 23, 2014 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 More sharing options...
adrian Posted May 23, 2014 Share Posted May 23, 2014 To be honest, I haven't had the need to use track changes yet either, although it sounds like it would come in handy if you are looking to report field level changes. 1 Link to comment Share on other sites More sharing options...
Craig Posted May 23, 2014 Share Posted May 23, 2014 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. 1 Link to comment Share on other sites More sharing options...
horst Posted May 23, 2014 Share Posted May 23, 2014 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'])); } 5 Link to comment Share on other sites More sharing options...
horst Posted May 24, 2014 Share Posted May 24, 2014 Wow. There is also a module out: https://github.com/netcarver/PW-ProcessFieldChangeNotifier 3 Link to comment Share on other sites More sharing options...
3fingers Posted May 24, 2014 Author Share Posted May 24, 2014 Wow. There is also a module out: https://github.com/netcarver/PW-ProcessFieldChangeNotifier Super find Horst! I'm wondering why this isn't present in the official Modules Directory, even as an alpha release.... Link to comment Share on other sites More sharing options...
netcarver Posted May 24, 2014 Share Posted May 24, 2014 Ahem, Super find Horst! I'm wondering why this isn't present in the official Modules Directory, even as an alpha release.... It's been there a pretty long time 3 Link to comment Share on other sites More sharing options...
3fingers Posted May 24, 2014 Author Share Posted May 24, 2014 Shame on me, I was looking for :processwire.com ProcessFieldChangeNotifier. My fault 2 Link to comment Share on other sites More sharing options...
Recommended Posts