Book Image

Yii Project Blueprints

By : Charles R. Portwood ll
Book Image

Yii Project Blueprints

By: Charles R. Portwood ll

Overview of this book

Table of Contents (15 chapters)
Yii Project Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Viewing a timeline of shares


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;
   }
...