finderQuery Parameter

To produce even more customized results, you may enter a SQL string in the finderOuery key, and it will run when the associated records are queried. You really should need to use this option only if your application requires a high level of database customization. Most of the time, you will be able to work just fine using Cake's built-in model functions. The has many relationship is extremely useful for helping to design effective databases. If you know that you intend to put a select menu in...

tableCells( data[array], oddTrAttributes[array],

data Table data arranged as rows and columns in an array oddTrAttributes null HTML attributes to be passed to odd rows evenTrAttributes null HTML attributes to be passed to even rows useCount false If true, adds the class name column- plus the number of the row to the lt tr gt element The html- gt tableHeaders function renders only the header row inside a table. Be sure to enter the lt table gt element tags by hand as HTML and include these table functions inside this element. The returned HTML...

generateTreeList

This function is a convenience method for returning a hierarchical array to be used in making HTML select boxes or breadcrumbs. generateTreeList amp model, conditions mixed , keyPath string , valuePath string , spacer string , recursive int conditions null SQL conditions as a string or as an array similar to conditions used in the find model function keyPath null A string path to the key, for example, n .Tag.name valuePath null A string path to the value similar to keyPath spacer '_' For each...

addCrumb( name[string], link[mixed], attributes[array] )

link null Can be keyed in an array for example, or entered as a string for example, ' posts add' if left blank, no link will be rendered around the text attributes HTML attributes to be passed to the lt a gt tag of the crumb Adding the home page of the site to the breadcrumbs array, for example, is simple using this function To display the breadcrumbs, however, you must use the html- gt getCrumbs function. Some parameters exist for the html- gt getCrumbs function to better manipulate how these...

dependent Parameter

When deleting records in a has one relationship, you may want both sides of the association to be deleted. For example, when a user has one profile and the user is deleted, you may want the associated profile to be deleted also. In these cases, the dependent key allows you to do this easily. By default, it is set to false. Set dependent to true to delete records in both tables when the delete action is run through the associated model. In the blog you are building, you have no need of a has one...

"Has and Belongs to Many"

The final association Cake can recognize for database table relationships is the has and belongs to many relationship. This relationship is powerful but also a little difficult to master. The more you experiment with has and belongs to many associations, the easier it will be to use them in your applications. In short, I've already discussed a one-to-one relationship with the hasOne association, and the hasMany association shows you how a one-to-many relationship is managed in Cake. What about...

Installing a Third-Party Script

Now that I've covered the basics of installing a vendor, let's use a third-party script in your blog application. Rather than build a wiki engine from scratch, let's choose one of the many open source text-parsing engines Textile. First, obtain a copy of Textile, which is available at http textile.thresholdstate.com. In this tutorial, I'll be using version 2.0. Once you have downloaded the file and decompressed it, you'll find the main engine file named classTextile.php. Place this file in the...

The bindModel() Function

Just as the unbindModel function helps you kill associations on the fly, the bindModel allows you to assign associations as well. Again, this function operates for just one query and then ceases to affect other succeeding model functions. This function follows the same syntax as the unbindModel function and contains two arrays one for the association to be bound to the current model and another for the models to be assigned to the association.

Symfony

Symfony entered the PHP frameworks arena early on and has remained popular. Its community is also large with developers groups, forums, a chat room, a wiki, and more. All of the main links to these various online groups and sites are available on Symfony's community web page Symfony actually is much different from CakePHP in its approach. In this book, I showed how to create a Cake project by renaming a folder and placing it on your server or localhost. In Symfony, you learn important commands...

Creating Individual Views

What do you do if you want to manipulate the views directly For example, say you wanted to get rid of the title at the top that reads Posts and replace it with Blog Posts. This is where individual views come in. Yes, the scaffolding is a nice feature that makes testing code quick and painless, especially if all you want to do is play around with the database to make sure it's working right. But it can't possibly read your mind, and it can create only some generic views. Adding or subtracting...

nestedList( list[array], attributes[array], itemAttributes[array], tag[string] )

attributes The HTML attributes to be passed to the list tag itemAttributes null The HTML attributes to be passed to the individual item lt li gt tags tag 'ul' The type of list tag to be used, either ordered or unordered lists lt ol gt or lt ul gt tags by entering ol or ul For each array and nested array passed in the list parameter, a new list tag will be called that is, for unordered lists, a new lt ul gt tag will be returned with the contents of the nested array parsed with lt li gt tags ....

A Simple Start: Running Cake on a Localhost Environment

Before you begin running Cake, you will need the following already working on your localhost see Appendix A for more details about installing these components Apache server with mod_rewrite MySQL Cake does support PostgreSQL, Microsoft SQL Server 2000, Firebird, IBM DB2, Oracle, SQLite, ODBC, and ADOdb, but I'll stick with MySQL in this book because it's the default database engine in Cake All three of these are easily installed with programs such as XAMPP by Apache Friends...

A Simple Page Request

Open the app controllers posts_controller.php file, and scroll to the View action. It should be similar to Listing 6-1. Listing 6-1. The View Action in the Posts Controller Post. , true 6 this- gt set post , this- gt Post- gt read null, id Processes are usually if not always dispatched to the controller. Here, the View action is processed by the controller, and the corresponding view file will be called when the process terminates. The first step of the action is to receive any parameters...