Testing if a list is empty in textpattern
Posted: June 14, 2012 Filed under: Applications, Technical Notes, Textpattern | Tags: Computers, conditional statements 1 Comment »Let’s say you have a section on a webpage like the “current courses” section in the right menu bar my teaching webspace.
This draws its list from articles in the section “teaching” that have “current_interest” as a category.
The problem comes between semesters while I am preparing my syllabi. If no course has a category “current_interest” you end up with a header and no content.
What you need is something that checks whether there is content to display and then presents different material based on the outcome of that check. You might delete the section entirely, or, as I have done, display a placeholder message. Read the rest of this entry »
Installing Zotero in Ubuntu
Posted: June 14, 2012 Filed under: Applications, Linux, Technical Notes, zotero | Tags: Computers, gnome, Linux, zotero Leave a comment »See the excellent post here.
http://anterotesis.com/wordpress/2011/11/installing-zotero-standalone-on-ubuntu-11-10/
To install the .desktop, I used the application launcher under system>preferences>main menu.
How to draw a circle in GIMP. Seriously.
Posted: June 14, 2012 Filed under: Applications, GIMP, Linux, Technical Notes | Tags: Computers, GIMP, graphics, Tips Leave a comment »I use GIMP, the free graphics software package, all the time. But boy it can be awkward at times. Here’s how to draw a circle or elipse (like the one in the photo below):
Ellipse select tool > Start selecting > Hold down shift > Click on the circle to select it > Edit (Menu) > Stroke Selection – Voila!
Alternative method: Select a circle again > Fill it > Select (menu) > Shrink few pixels > Delete
Seriously?
Adding an attribute for title to a yii widget
Posted: February 24, 2012 Filed under: Applications, Technical Notes, Yii | Tags: Computers, journal incubator, scaffolding, Tips, workflow manager, YII Leave a comment » The Yii fileview.php
by default uses the [zii.widgets.CDetailView
] to display all examples of a given model. In the standard scaffolding produced by the gii
utility, this widget consists of references to attributes of the model without any further information (e.g. attribute names and the like):
<?php $this->widget('zii.widgets.CDetailView', array( 'data'=>$model, 'attributes'=>array( 'editorialInstance_id', 'journal.shortTitle', // a reference to a relational attribute 'type', 'LastNamesFirstName', // a reference to a compound attribute ),
In this minimalist form, yii will calculate an appropriate label for the attribute on the basis of the attribute name: so, for example, in this case, editorialInstance_id will be appear in the view labelled “Editorial Instance” because Yii understands camelCase naming conventions and knows to strip off _id (it’s that good!).
A problem with this, however, is that we also provide customised label names as part of the attributeLabels()
method in our Model controller. Since that method allows arbitrary names, and since CDetailView
attempts to calculate labels on the basis of the attribute name, it is highly likely that the labels for different attributes will get out of synch in different places in your site. To give an example: in this particular case, the model for editorialInstance might have defined the label for editorialInstance_id as “ID” rather than “Editorial Instance”: since CDetailView
doesn’t check to see what you had on attributeLabels()
in the model class, switching from an edit view to an index will mean that the label of the attribute switches. Read the rest of this entry » Understanding Relation Models in Yii
Posted: February 24, 2012 Filed under: Applications, Technical Notes, Yii | Tags: Computers, database, queries, relational queries, scaffolding, Tips, YII Leave a comment » 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
Posted: February 24, 2012 Filed under: Applications, Technical Notes, Yii | Tags: compound queries, Computers, database, queries, scaffolding, Tips, YII Leave a comment » Let’s say you have a database table called persons with separate attributes (fields) forlastName
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 » Yii Ensuring that key terms are always linked
Posted: February 24, 2012 Filed under: Applications, Technical Notes, Yii | Tags: Computers, journal incubator, linking, scaffolding, Tips, workflow, YII Leave a comment » As we are building our workflow manager, we are discovering that we develop a more intuitive interface if some terms are always hyperlinked and point to a standard presentation of the relational information. One example of this might be names of people associated with the workflow (editors, authors, copyeditors, production assistants). An intuitive internal navigation method seems to be to have the names of these people always hyperlinked with the hyperlink always pointing to the person’s profile page. Read the rest of this entry »Yii Authentication
Posted: February 20, 2012 Filed under: Applications, Technical Notes, Yii | Tags: authentication, Computers, Tips, YII Leave a comment »In the controllers established by gii, yii’s scaffolding tool, there is a standard method called accessRules() that defines what users can do what actions.
set date and time from commandzone
Posted: November 22, 2011 Filed under: Applications, Linux, Technical Notes | Tags: command-line, Computers, Linux, Tips Leave a comment »As the title suggests
Change date using touch
Posted: October 18, 2011 Filed under: Applications, Linux, Technical Notes | Tags: Computers, Linux Leave a comment »#!/bin/sh
for i in *; do
touch -r "$i" -d "-1 years" "$i"
done
Extracting a catalogue of element names from a collection of XML documents using XSLT 2.0
Posted: September 15, 2011 Filed under: Journal Incubator, Projects and Societies, Research, Technical Notes | Tags: Computers, digital humanities, journal incubator, Projects and Societies, scholarly publishing, Tips, xml, xslt Leave a comment »We are trying to build a single stylesheet to work with the documents of two independent journals. In order to get a sense of the work involved, we wanted to create a catalogue of all elements used in the published articles. This means loading as input document directories’ worth of files and then going through extracting and sorting the elements across all the input documents.
Here’s the stylesheet that did it for us. It is probably not maximally optimised, but it currently does what we need.