Yii Framework Forum: Undefined variable issue on the first Yii app. - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Undefined variable issue on the first Yii app. Rate Topic: -----

#1 User is offline   dubby 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 10-February 09
  • Location:Melbourne, Australia

Posted 10 February 2009 - 10:58 PM

I have successfully set-up Yii following the documentation with the page loading but I am unable to get running the first step in the first Yii app found in the cookbook.

I am getting the error: Undefined variable: pages

in file: /home/developer/yii-first/protected/views/user/list.php(8)

Referring to line 8: 00008: $this->widget('CLinkPager',array('pages'=>$pages));

This is on the home page. The home page is fine as soon as I revert /protected/views/site/index.php back to how it was originally.

Any ideas?

Thanks,
Dubby.


0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 11 February 2009 - 06:48 AM

Did you change your SiteController.php?
0

#3 User is offline   dubby 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 10-February 09
  • Location:Melbourne, Australia

Posted 11 February 2009 - 06:21 PM

Thanks for the reply.

I have just followed the installation at:
http://www.yiiframew...rt.installation AND
http://www.yiiframew...start.first-app

which includes:

Running yiic webapp (from which the basic template site runs ok)
Modifying /protected/config/main.php to include the database parameters
Created the database and User table.
Running 'model User' and 'crud User'

The site works at each step along here fine.

I didn't see any mention of changing SiteController.php

From this base install I started following the tutorial here: http://www.yiiframew...doc/cookbook/5/ but at the first step of replacing the contents of file /protected/views/site/index.php created the 'undefined variable: page' error.
0

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 11 February 2009 - 08:07 PM

The cookbook page does not apply because the user list view requires $pages. You may refer to UserController::actionList() to see how to provide this variable.
0

#5 User is offline   dubby 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 10-February 09
  • Location:Melbourne, Australia

Posted 11 February 2009 - 11:22 PM

I'm sorry but I still don't follow.

The cookbook page does not apply to what?

The cookbook example that I am trying needs User and User needs $pages. It seems that there is a step I overlooked somewhere that I cannot find.

Edit: I looked into UserController::actionList() but wasn't sure what to do. I am just starting out with Yii and I have read through the definitive guide but am trying to learn from from these exercises so am quite naive at this time.
0

#6 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 12 February 2009 - 06:47 AM

The view "/user/list" was originally designed to be used by the "list" action in the UserController, which will supply a $pages variable to the view. The cookbook page tries to reuse this view in the "index" action of SiteController.

I recommend you follow the blog demo to learn Yii, instead of cookbook. The latter is meant to solve individual problem that you encounter during your development.
0

#7 User is offline   dubby 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 10-February 09
  • Location:Melbourne, Australia

Posted 15 February 2009 - 09:29 PM

Thanks again qiang.

Is there a tutorial for the Blog? I have found links to the blog demo itself and the SVN repository but not an explanation of how it works.
0

#8 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 15 February 2009 - 09:39 PM

A tutorial is coming in the next few days.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users