The easiest way to display new content is to simply list it so that the newest items are shown first. On our timeline page, we want to provide the user with the ability to share something, view information about the user they are viewing (such as the number of shares, followers, and followees), and view things that the user has recently shared. To do this, we're going to take advantage of CListView
loaded asynchronously from our main timeline view. This will allow us to reuse this view later on by simply making a GET
request to an endpoint that we'll create later. In our TimelineController.php
file located at protected/controllers/
, implement the actionIndex()
method:
public function actionIndex($id = NULL) { // If the ID is not set, set this to the currently logged in user. if ($id == NULL) { if (Yii::app()->user->isGuest) $this->redirect($this->createUrl('site/login')); $id = Yii::app()->user->username; } ...