10 Yii 1.x Framework and MVC “Beginner” Questions & Problems Solved

Sometimes "experience" means all the little stuff that no one ever bothered to write down. Learning code through doing will lead you on a zig-zag path from one problem to the next, that is different per-project. In starting a big website made with Yii, having never touched the framework before, I took notes on some of the issues and questions that arose while developing...

Yii 1.x: Adding Title Tags, Meta Descriptions, and Other SEO-Related Tags

As a followup to my post about SEO-Friendly URLs using Yii, I figured I would post this function I created for displaying SEO-related tags in the layout.Using the Gii generator with the Yii Framework, a custom base controller is created that is a parent for the others. It already contained a property called pageTitle that was used in some of the views. I decided to keep this location and expand upon it by adding in some more properties related to search engine optimization, and then create a function to display the HTML...

Yii 1.x: How to Search a HAS_MANY relation using CDbCriteria Compare()

Using Yii's implementation of ActiveRecord makes querying a database much easier for simple queries. For more complex situations, you will still find yourself having to write some straight SQL on occasion. In this case, using a custom query was not necessary. I was trying to add another search parameter, using the AR compare() method, to search a relation with a HAS_MANY relationship, and it was displaying an "unknown column" error. Without a proper example, it wasn't clear at first how to get this work...

Clean SEO-Friendly URLs for Yii 1.x Pages

Creating SEO-friendly permalinks for an application built using the Yii Framework was a multi-step process. I figured I would outline each part. First, you can use slugs to access your view actions with the help of an extension and entries to your urlManager. Removing "index.php" is as simple as adding a few htaccess rules and changing two options. To Force trailing slashes, some code can be added to your base controller. And lastly, to give yourself cleaner "/site/page/" URLs, some more entries can be added to your urlManager...

Yii 1.x Framework Intro: Starting a New Database-Driven Website

In creating my first Yii application, there were a few hurdles and stumbling blocks along the way. One of the first guides/tutorials that a new user to the Yii PHP framework is directed to is the "Creating Your First Yii Application" in the "Definitive Guide to Yii" . This is kind of a companion piece that has extra explanation, plus the first steps I made to start turning the example app (generated skeleton) into my custom web application.