Jump to content
Larry Ullman's Book Forums

"The Yii Book" Now Available


Larry
 Share

Recommended Posts

No problem at all, Jonathon. You have every right to ask. You see...I had a couple of days while waiting to hear back from the tech editors on chapters 11 & 12, and so I thought "Why don't I just see about figuring out a couple of formatting/layout issues (PDFs) while I wait?" And I did that, which then required that I make some formatting changes to all the written material to that point. And since I was doing that, why not go through the entire book and make sure all the chapter references are correct and linked? And why not re-test all the code, just to be sure? And, hey, those images are a little blurry. Why don't I retake all the images while I'm at it? And then it's been a week and a half!

 

But I've done all that for all the existing material, am editing Ch 11 now, and will edit Ch 12 probably tomorrow morning or afternoon, and then send an update. Thanks for your patience!

Link to comment
Share on other sites

Yes, you're right: the changes will make me happy. Hopefully the readers will appreciate them, too. They're little things, but I think will lead to a nicer looking book (in PDF format, anyway).

  • Upvote 1
Link to comment
Share on other sites

Saw you included a chapter on authentification this time. That's pretty awesome as I'm currently considering using YII for a new project. I'm wondering if I should use YII's auth, depend on phpBB3 (as all users are currently there) or write a "man-in-the-middle" service.

 

I did the last thing for a Wordpress plugin that required login before you could leave a comment. The goal was getting as few dependencies to both Wordpress and phpBB3 as possible. The plugin still works like a charm, though not publicly available. I think the end result was so good I consider doing it again.

 

The last thing I consider is Facebook, Google, Twitter, whatever-auth. I don't currently like that.

 

Looking forward to read now, Larry. Almost posted some of these questions just a few days ago.

Link to comment
Share on other sites

  • 2 weeks later...

I got a small problem with bootstrap extension in for yii due to the fact that if you use their theme then the site view files are in the themes folder under bootstrap, which is very ugly. Every time i try to move the files i loose the bootstrap theme css. The thing that is interesting is when you use the bootstrap generator to generate CRUD in gii the files all go to their original place in the protected folder. So i hope Larry in your Extensions chapter that you will include some reference on how to install bootstrap and possibly bypass such problems.

Link to comment
Share on other sites

I'm looking forward to your extension piece for Bootstrap. I used http://www.cniska.net/yii-bootstrap/  I could get the form to display fine, but I couldn't link the the validation through. So It kept failing even when i'd selected a radio button. I suspected that my approach prior to implementation would be wrong. But will be good to see your chapter and also this extension, it looks good.

Link to comment
Share on other sites

I am having trouble with Yii-Bootstrap the same as Jonathon pointed out above, i thought you were going to do that as it was in your contents.

 

Seriously right now i have my hands in the air and am screaming literally, i bet Jonathon will be doing the same. I really believe that just customizing myself was better over using Yii-Bootstrap, after getting to know it a little more i really didn't like it. I guess i can take a look at Yii-Booster and see if it will work for me, it does look to be better. I'll try it now urgggghhhh! :angry:

Link to comment
Share on other sites

An update i like Booster it is much easier to install and does not hinder the original structure of Yii. I will use that as i don't have to come back to manually edit the framework files css each time i do a Yii upgrade.

 

Will you use Boilerplate too or just Yii-Booster?

Link to comment
Share on other sites

Well, I'm glad I choose YiiBooster then! Just doing it, but I mention Boilerplate. I should add that the goal in the Extensions chapter is just to give a sense of:

  • What extensions are
  • The range of what they're capable of
  • Some examples of how they're used

I'm not going into too much detail on any one, as that's not a good use of book space (i.e., I'm going with a teach a man to fish approach).

Link to comment
Share on other sites

That's great, well i had a look at Booster in more detail and i don't see the need to use that either the Yii-Bootstrap, you get more flexibility with your own custom coding. There is also the factor that hard coded CSS will load faster than CSS which has to be interpreted by a widget, that could be costly on a site with many page views. I think the gold is in the Twitter Bootstrap not the silly extensions.

Link to comment
Share on other sites

I tried to remake my project using Yii-Booster, it all seemed okay but then i relize now that you can't use HTML5 with it and also captcha wouldn't work either. Seriously i am pissed off now, i spend three days coding stuff together to find out that now it doesn't work smoothly and there is no help online for fixing the problems.

 

I seriously think that the way i started of just implementing the twitter boostrap framework and doing my own customizations was far better. So far all of the extensions i have used have sucked and have been more of a hinderence than a benefit.

 

The only things that have been useful was changing some of the things you noted Larry in your chapters, ive done that and that all worked 100%.

Link to comment
Share on other sites

You actually have to use HTML5 with YiiBooster, because Bootstrap requires HTML5. But the main argument for using one of the Bootstrap extensions is that they create widgets that a formatted using Bootstrap.

Link to comment
Share on other sites

They didn't mention changing from Traditional to HTML5 in the Yii-Booster Setup documentation, i just changed it. I managed to get Captcha to work which is good so i will continue on with Yii Booster. It would be nice if you could explain in your chapter on Extensions of how to use and install the Yii Booster, and which css files would be safe to edit. The problem i see with making your own edits is that if they upgrade you would have to go back and edit all those parts again. So i guess adding your own rules to the bottom of the style sheet seems to be the best way and then its just a matter of copy and pasting them to the upgraded sheets.

 

The widgets will slow down the loading process rather than hard coding in the css.

Link to comment
Share on other sites

Larry Sorry about my bitching the other day, i just needed to cool down and get some patience, that always seems to work. All is going well so far.

 

I just wanted to ask if possible, you may already be doing this but in the Javascript chapter for Yii, would it be possible to have a how to's for adding say dynamic text boxes, say we have an item and we need to add in an Attibute and a Value, this could be for example condition, new. But for attibutes and value text boxes a customer may require 0 to as many as they need.

 

The other things that would be useful is for username using javascript and ajax if they username was taken or not. I know we can already set this with the unique attribute in the model but what if we wanted to customize our message more rather than using the standard error message.

 

Another thing say we had to load in our product images up to 10 for example, how can we upload but then show the recent uploaded picture to the page, then load up another one, then possibly delete one. Anything that would help for the process of this would be helpful. I couldn't find any plugins online for this to do what i need so it looks like it needs to be a custom job.

 

Would be grateful if you could add any info in the book to help out with these thanks.

Link to comment
Share on other sites

No problem, Edward. I had a frustrating week trying out different extensions myself. Some install and work better than others. 

 

As for the specific ideas, I'll see what I can do. With the username option, if you edit the error message in the model, that should apply during Ajax validation. 

Link to comment
Share on other sites

Well YiiBooster seems to be quite stable, the only thing was when working with forms you only have to add:

 

<?php echo $form->textFieldRow($modelUser,'email',array('class'=>'span5','maxlength'=>60)); ?>

 

rather than all the standard:


    <?php echo $form->labelEx($modelUser,'email', array('class'=>'control-label')); ?>
    <?php echo $form->textField($modelUser,'email',array('size'=>60,'maxlength'=>60)); ?>
    <?php echo $form->error($modelUser,'email'); ?>

 

So you can't get direct access to label or error as they have fitted all of them into textFieldRow.

 

One other thing i forgot to mention yesterday was where in Yii should we add our own classes, i will definetly need to add some additional ones for my project to work. I thought of the top of my head that we might add them into components but i am not sure.

 

I was also thinking yesterday if they were some small parts of my project i could not complete myself then possibly i could hire you for some small parts. It really depends whether i can get it done myself or not, but only small parts, nothing that would take up too much of your time.
 

Link to comment
Share on other sites

You can put new classes into the components folder, or extensions, depending upon what they're used for. 

 

If you need some final help later on, we can certainly talk about employing me then (and thanks).

Link to comment
Share on other sites

Thanks. I think i have found a situation where Yii-Booster extensions don't work, well you know we have to use the Yii encode function to protect against XSS attacks, well look at this situation.

 

<?php

Yii::app()->user->setFlash('warning',
    "<p>This is your email <strong>(echo CHtml::encode($modelUser->email);)</strong> </p>");

$this->widget('bootstrap.widgets.TbAlert', array(
'block'=>true, // display a larger alert block?
'fade'=>false, // use transitions?
'closeText'=>'false', // close link text - if set to false, no close link is displayed
'alerts'=>array( // configurations per alert type
'warning'=>array('block'=>true, 'fade'=>false, 'closeText'=>'false'), // success, info, warning, error or danger
),
));

 

We can't add that encode function into the extension, it won't work, so we have to use the manual bootstrap css for alerts in this situation.

 



?>

Link to comment
Share on other sites

Actually i am not messing around with CSS too much right now, as there is Yii-Boilerplate which they recommend you install rather than just Yii-Booster alone which i did. I have no idea how to install Yii-Boilerplate, don't understand what they are talking about at all, so wondered whether it was worth the hastle. The trouble with installing the Yii-Booster extension is that the Yii layout files main.php, column1.php and column2.php are still using blueprints css. I did wipe out the blueprints before and changed all to bootstrap but now like Jonathon i don't want to do too much incase i make too many mistakes, i really hate going back to redo the same stuff. That's why i wasn't here for a while, needed time to take a rest before i could start it all again.

Link to comment
Share on other sites

I was fixing a small bug on my Yii site today, i did change the login page over to the user model to reduce the models like you said Larry on page 248 "Using the Existing Model". But this code only partially works, we also need to set the the default login page in our main.php file in config folder otherwise when we try to access a controller we need authentication to it will always take us back to site/login.

 

'user'=>array(
            'loginUrl'=>array('user/login'),
            // enable cookie-based authentication
            'allowAutoLogin'=>false,
            'authTimeout' => (60*15) // session timeout 15 minutes
        ),

 

Hope this helps out!

Link to comment
Share on other sites

 Share

×
×
  • Create New...