Yii skeleton app

Alright, I will update this as I try to make it run without exception. Might break a few things but thought it can be helpful for newbies like me looking for a better start than yiiblog.

download http://subversion.apache.org/ fire up the cmd

paste the svn command line found in previous post… you should be downloading the codes.

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘post.created’ in ‘order clause’

Change all post.fieldname to t.fieldname on Controller and Views

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1364 Field ‘created’ doesn’t have a default value

http://www.yiiframework.com/doc/cookbook/10/

http://www.yiiframework.com/doc/api/CTimestampBehavior

in Model




	public function behaviors(){

		return array(

			'ParseCacheBehavior' => array(

				'class' => 'ParseCacheBehavior',

				'attributes' => array('content'),

			),


			/* Remove this

                        'AutoTimestampBehavior' => array(

			  'class' => 'AutoTimestampBehavior',

			  'class' => 'application.components.behaviors.AutoTimestampBehavior',

			)

                         */

                        

                        //added this codes

         		'CTimestampBehavior' => array(

  			'class' => 'zii.behaviors.CTimestampBehavior',

  			'createAttribute' => 'created',

  			'updateAttribute' => 'modified',

  			'setUpdateOnCreate' => true,

  		)

		);

	}


	



When creating a new post

Missing argument 1 for Post::beforeValidate(), called in D:\Domains\altruism.com.my\wwwroot\framework\base\CModel.php on line 147 and defined


	

//REPLACE

protected function beforeValidate($on) {

   if ($this->isNewRecord)

   $this->user_id = Yii::app()->user->id;

return parent::beforeValidate($on);	

	}  

//WITH

protected function beforeValidate() {

  if ($this->isNewRecord)

  $this->user_id = Yii::app()->user->id;

		return parent::beforeValidate();	

}  



Will add more if i get it to run…

I wished someone who have converted this to 1.1 can help out…as someone new to yii, its taking me long

I get this when I register a new user but can’t find anywhere that filled up the about field.

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1364 Field ‘about’ doesn’t have a default value

I was working on cleaning up the errors in the Skeleton app as well. The error that was generated from registering a new user is due to this code in the User model, User.php:




	public function safeAttributes() {

		return array(

			//parent::safeAttributes(),

			'update'=>'about, password, password_repeat',

			'updateAdmin'=>'about, password, password_repeat, group_id',

			'login'=>'username, password, rememberMe',

		);

	}



safeAttributes() was removed in 1.1 and became part of the validation rules as detailed in the Definitive Guide here: Upgrading from 1.0 to 1.1

I added these lines to the validation rules:


array('about, password_repeat','safe', 'on' => 'update, updateAdmin'),


array('username, rememberMe','safe', 'on' => 'login'),

Some of the other fields were already covered by other rules which should make them ‘safe’ under those scenarios. That is, if I am understanding correctly.

Anyway, user registration now works on the Skeleton app under 1.1.3. I am digging around in it and I’ll see what else comes up.

An empty case of safeAttributes is in the Post Model, Post.php




	public function safeAttributes() {

		/**

		* ActiveRecord is extended to know that 'required' attributes are 'safe'.

		* We return a empty array so that it won't think 'created' and 'modified' are 'safe'.

		* It will still know 'title' and 'content' are safe because they are 'required'

		*/

		return array(); 

	}



You may want to remove that as well.

Hello,

I’ve uploaded the Yii skeleton app with my modifications to make it work with yii-1.1.6.r2877

you can download it here : websitebuildingsolutions.com/Yii_skeleton.rar

In the tables creation file - the user table creation should be :


CREATE TABLE IF NOT EXISTS `user` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `username` varchar(50) NOT NULL,

  `password` char(50) NOT NULL,

  `email` varchar(100) NOT NULL,

  `email_visible` tinyint(1) NOT NULL DEFAULT '0',

  `notify_comments` tinyint(1) NOT NULL DEFAULT '1',

  `notify_messages` tinyint(1) NOT NULL DEFAULT '1',

  `about` text DEFAULT NULL,

  `aboutParsed` text NOT NULL,

  `group_id` int(11) NOT NULL DEFAULT '2',

  `email_confirmed` char(21) DEFAULT NULL,

  `created` datetime DEFAULT NULL,

  `modified` datetime DEFAULT NULL,

  PRIMARY KEY (`id`),

  KEY `group_id` (`group_id`)

) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;

the change from the original file - about text DEFAULT NULL,

The only error I get now (from what I sew) is in jquery:

elem.attributes is null

but it looks like everything works…

Hope it will help

Do you mind if I modify the svn with your changes? In fact, I could even add you as an admin

First, shani, thanks for the fix.

And much thanks to the guy who put it together in the first place. In learning Yii the first thing I was thinking after making a few test projects was making a new skeleton of my own until I stumpled onto yours. I was working on getting it up and running for the latest version of yii as well, you saved me a bunch o time no doubt.

I found one other error that I fixed as well that I wanted to pass on. If you go to posts section while you are not logged in and try to create a post, you get a “Property “AccessRule.message” is not defined.”, meaning basically it can’t find the variable that is supposed to be holding the “not logged in” or whatever.

The fix is to take this file:

/protected/components/AccessControlFilter.php

in the AccessRule class at or around line 75, or anywhere where the class properties are defined, add this:




	/**

	 * @var string the error message to be displayed when authorization is denied by this rule.

	 * If not set, a default error message will be displayed.

	 * @since 1.1.1

	 */

	public $message;



seems to fix that issue.

Christopher

I just put some updates in to get the app working on Yii 1.1.6. It still uses the old yii default template, and the old menu component… It was just a quick fix

Thank you so much, jonah.

I’ve spent the last few months trying to learn a PHP framework. I’ve always rolled my own. First CodeIgniter, then Kohana and now Yii. I’ve gotten more accomplished in the last six hours with Yii than I have with CI and KO3 since November 2010.

It seems rudimentary to me that a framework would offer a working skeleton to give the developer a quick start. After all, isn’t that is what a framework is for - quick development? And that (speaking for myself) is lacking with the other frameworks I’ve tried. Thanks for helping me get started.

In file /protected/modules/textedit/components/TextEditor.php, around lines 64,65 change…




loaddata: {id: $(this).attr('id')},

submitdata: {id: $(this).attr('id')},



to…




loaddata: {id: this.id},

submitdata: {id: this.id},



I’m not sure this is the proper way to do it but it worked for me.

I didn’t get a notification about that post… If it’s still relevant - sure, you can modify the svn with my changes.

cool,but no download available now~~~

Checkout:

using one of these: http://en.wikipedia.org/wiki/Comparison_of_Subversion_clients#Subversion_clients_comparison_matrix

Edit the /config/main.php

Update or coment the param urlManager