Understanding Relation Models in Yii

The core of any database driven website is its ability to handle table relations (if that sentence didn’t mean anything to you, you should first do some reading about relational databases, database design, and normalising data: an introduction aimed at textual editors can be found in my article “What digital editors can learn from print editorial practice.” Literary and Linguistic Computing 24 (2009): 113-125) One of the really useful things about the Yii MVC framework is the extent to which it allows you to systematise and automate the process of establishing these relations. Read the rest of this entry »

Creating compound attributes in Yii

Let’s say you have a database table called persons with separate attributes (fields) for lastName and firstNames. Elsewhere in your website, you want to refer to the underlying record in this table using the person’s whole name as a single entity (e.g. to provide a link, for example: <a href="http://example.com/index.php?r=Person/view&id=1">Jane Q. Public</a>. Sometimes, you might be able to refer to the two attributes separately. For example, if you simply wanted to echo the content in a view somewhere you could use code like this:
<?php echo CHtml::encode($data->person->firstNames) . ' ' . CHtml::encode($data->person->lastName); ?> 
This is a little inefficient if you are doing it a lot throughout your site, because you need to keep re-entering the same code correctly over and over again (and avoiding this is a main reason for going with an MVC framework like Yii in the first place). But the real trouble comes if you want to use the attributes in a context where the method you are invoking expects a single attribute—as is the case, for example, with the yii linking method CHtml::link. The way round this is to create a new compound attribute in your model. This means taking the two underlying attributes in your table and combining them into a single attribute already arranged the way you want that you can then invoke in other methods. Read the rest of this entry »

Back to the future: What digital editors can learn from print editorial practice.

The last decade or so has proven to be a heady time for editors of digital editions. With the maturation of the digital medium and its application to an ever increasing variety of cultural objects, digital scholars have been led to consider their theory and practice in fundamental terms (for a recent collection of essays, see Burnard, O’Keeffe, and Unsworth 2006). The questions they have asked have ranged from the nature of the editorial enterprise to issues of academic economics and politics; from problems of textual theory to questions of mise-en-page and navigation: What is an Edition? What kinds of objects can it contain? How should it be used? Must it be critical? Must it have a reading text? How should it be organised and displayed? Can intellectual responsibility be shared among editors and users? Can it be shared across generations of editors and users? While some of these questions clearly are related to earlier debates in print theory and practice, others involve aspects of the production of editions not relevant to or largely taken for granted by previous generations of print-based editors. Read the rest of this entry »
Follow

Get every new post delivered to your Inbox

Join other followers: