Larry Ullman

Translating Geek Into English

Rendering View Files in Yii

In the MVC architecture, the Controller reacts to a user request. In doing so, the Controller often loads an instance of a particular Model and then renders a specific View. “Rendering” just means compiling all the pieces together, including static text (HTML and such) and the output from executed PHP code. For example, when a user goes to a page for updating a record, the Controller loads the associated record, and then renders the “update” View, which will display the pre-populated form:

\[php\]

public function actionUpdate($id) { $data=$this->loadModel($id);

\[/php\]

Note: That method would also have code in it for handling the submission of the update form, but I’m trying not to complicate the discussion.

As you can see in that code, the render() method, defined in the CController class, is how a View file is chosen for rendering. The first argument to the method is the View file to be rendered, without its .php extension. The render() method will render the View file within the appropriate layout file. In other words, the View file will be rendered with its context. The above code renders update.php, for the associated Controller, wrapped within the views/layouts/main.php layout file (the default).

Adding a CDN; Improving Site Speed

I’m in the process of implementing Amazon’s CloudFront as a CDN (Content Delivery Network) for my site (in order to improve performance). Once I feel comfortable with how it’s working (it seems to be now, but it will take a day or two to fully roll out), I’ll formally write up what I did and why. In the meantime, if you see anything crazy, please let me know.

What is Larry Thinking? #36 => Becoming a Better Programmer and More!

In this edition…

About This Newsletter

No real theme to this newsletter: a couple of links to interesting things online, recommendations of two blog postings to consider, answers to two recently submitted questions, and some news. I turned a frequently asked question into a “What is Larry Thinking?” topic: how to become a better programmer. I’ll follow up on that topic in a future newsletter, too. Other forthcoming subjects include: starting a new Web site/business, making a career out of programming, and how to organically grow a Web site.

Several Excerpts from "Effortless Flex 4 Development" Published Online

\[intlink id="1579" type="page"\]\[/intlink\]

” (technically, Peachpit’s sister company New Riders is the publisher), has posted excerpts from the book available for reading—for free—online. As of today, you can read on the following subjects:

You can see all the articles and blog posts that I’ve written for Peachpit Press by viewing my writer’s page there.