Larry Ullman

Translating Geek Into English

"The Yii Book", Code for Chapters 22 & 23

Chapters 22 and 23 of " The Yii Book" are example chapters, in which I don’t cover new material but rather put together previous material in a more complete context. These example chapters have been popular in my other books, so I thought I’d include two in this book. The specific examples I came up with are:

The blog (Chapter 22) is a more complete version of what was commonly used as an example throughout the entire book. For the e-commerce example, I came up with the idea of selling books (imagine that!).

Much Ado About Yii

Without much formality (aside from the Shakespeare), I’d like to share four bits of Yii-related news:

  • The Release of Yii 2
  • Progress on “The Yii Book”
  • Looking ahead to “The Yii 2 Book” (aka, the second edition)
  • An online Yii 2 presentation I’m doing this Thursday, October 23, 2014 for Nomad PHP

"Faster Web Development with Yii Framework 2" Presentation on NomadPHP

On October 23, I’ll be doing an online presentation titled “ Faster Web Development with Yii Framework 2”. In this presentation, I’ll be introducing the Yii framework in general, and version 2 in particular. Keep reading this post or click the “Faster Web Development with Yii Framework 2” link, for an introduction to the presentation.

This is a paid event, put on by NomadPHP, but the cost is only $15, for either live attendance or a video afterwards.

Adding JavaScript to a Page in Yii

The first thing you’ll need to know to use JavaScript and jQuery in Yii is how to add JavaScript to a Web page. As with any standard Web page, there are two primary options:

  • Link to an external file that contains the JavaScript code
  • Place the JavaScript code directly in the page using SCRIPT tags

Just as I assume you’re already comfortable with JavaScript, I’ll also assume you know the arguments for and against both approaches. (Technically, there’s a third option: place the JavaScript inline within an HTML tag. This is not a recommended approach in modern Web sites, however, and I won’t demonstrate it here.)

This is an excerpt from Chapter 12, “JavaScript and jQuery,” of “ The Yii Book“.

Linking to JavaScript Files

External JavaScript files are linked to a page using the SCRIPT tag:

\[html\]\[/html\]

The contemporary approach is to link external files at the end of the HTML BODY, although some JavaScript libraries must be included in the HEAD.