Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Status Stream 'stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '-fromself.tpl.php', $datatags ); } elseif( $data['poster'] == $data['profile'] ) { $this-registry-getObject('template')-addTemplateBit( 'stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '-user.tpl.php', $datatags ); } else { // network updates $this-registry-getObject('template')-addTemplateBit( 'stream-' . $data['ID'], 'stream/types/' . $data['type_reference'] . '.tpl.php', $datatags ); } } } else { If there were no updates, we display the none template. $this-registry-getObject('template')-buildFromTemplates( 'header.tpl.php', 'stream/none.tpl.php', 'footer.tpl.php'); } } So, if we had our templates in place at this stage, bringing all of this together, adding the controller to our database, and viewing /stream what would we see? [ 192 ] Download from www.eBookTM.com Chapter 6 This is. | Status Stream stream- . data ID stream types . data type_reference . -fromself.tpl.php datatags elseif data poster data profile this- registry- getObject template - addTemplateBit stream- . data ID stream types . data type_reference . -user.tpl.php datatags else network updates this- registry- getObject template - addTemplateBit stream- . data ID stream types . data type_reference . .tpl.php datatags else If there were no updates we display the none template. this- registry- getObject template - buildFromTemplates header.tpl.php stream none.tpl.php footer.tpl.php So if we had our templates in place at this stage bringing all of this together adding the controller to our database and viewing stream what would we see 192 Download from www.eBookTM.com Chapter 6 This is the basics of our status stream. We can now look at adding comments likes and dislikes to the stream. Comments likes and dislikes The functionality behind adding comments likes and dislikes is very similar to the work we did in Chapter 5 in developing the statuses on a user s profile. The concept to adding these to the stream is fairly straightforward. Firstly we create an empty array of comments likes dislikes for each status. This way if a post has no comments likes or dislikes then by caching the empty array and sending it to the template we don t see a blank list where comments should be. If there are comments they are added to the empty array making it non-empty cached and sent to the template. Although the method is the same for the three aspects comments require one database query whereas likes and dislikes combined require another so let s add in support one at a time. Comments Take the status IDs we retrieved earlier and create empty arrays for each of them. status_ids implode IDs start array foreach IDs as id start id array Copy our new array of empty arrays to be used for comments. comments comments start Query the database for comments. sql SELECT p.name as commenter c.profile_post c.comment