Setting a “Label” property tip for FarCry 5

Quick tip which might fix some problems for people as it did for me today.

I had a custom object for a calendar where the main title was “EventTitle”. Now as you may know FarCry uses the “label” and “title” property from types.cfc by default.

As I wasn’t using this default property my label value was “incomplete” in the database. This didn’t really bother me as it would never be seen, however it was preventing my content object from being approved. I wasn’t getting an error message when attempting to publish, it’s just that the row would remain in draft.

I figured if I could add a value to the label property I would be able to approve the object. A quick search on the docs site gave me a nice little attribute to add to your type cfproperty of bLabel=”true/false”. What this does is maps the property to the types.label property.

This is a nice little solution, now the “label” property can be populated by any property I choose (i.e. EventTitle) and I’m not restricted to name my propery “label” or “title” etc.

Btw this also fixed my publishing issue.

This works as of FarCry 5.1.4

No Comments

Development configuration tips for Ubuntu

I just setup my machine at home with Ubuntu 8.10 (desktop) which was so easy think I saved hours off the time it would normally take with Windows. So much is already installed and ready to go and with apt (or the Synaptic package manager) it’s super quick to download and install extra things things like MySQL, PHP, Apache, Java etc

Here are some notes which helped me out when configuring some of these development tools.

This assumes you’ve already installed Apache and MySQL, for notes on installing these I found this article to be a great resource.

If you get this message when you restart Apache, “Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName“, edit /etc/apache2/conf.d/fqdn and add “ServerName localhost”:

sudo nano /etc/apache2/conf.d/fqdn

Load the mod_rewrite module for Apache
sudo a2enmod rewrite

Enable your Apache vhosts
I already had all my vhosts defined in separate .conf files on my windows box, so I copied them all into /etc/apache2/sites-available and setup symbolic links from my /etc/apache2/sites-enabled:

sudo ln -s /etc/apache2/sites-available/mysite.conf /etc/apache2/sites-enabled/mysite.conf

Download and install PHP
sudo apt-get install php5 libapache2-mod-php5

PHP connector to MySQL
sudo apt-get install libapache2-mod-auth-mysql php5-mysql

Install MySQL Administrator
sudo apt-get install mysql-admin

Install subversion
sudo apt-get install subversion

I am also using Pulse to manage my eclipse development environment so I needed Java which I got from the Synaptic Package Manager (sun-java6-bin). Pulse is super cool, I used the standard cfeclipse profile with the addition of the PHP PDT (for developing in PHP).

10 Comments

How to do a case-sensitive test of your codebase

Cross platform development and/or hosting makes for interesting times. Making sure that your entire codebase and configuration are compatible and work in different operating environments is obviously paramount to a successful project, particularly if you are “releasing” a product to the public either open source or commercially.

At Lynch Consulting all of our production servers are Linux based but the development team spreads across Linux, Mac and the occasional Windows machine. We are looking at implementing the FarCry 5.x framework for some new projects and I wanted to test the codebase in an environment as close as I could to our production setup (i.e. Linux). This is quite an important step because Linux based machines are case-sensitve, whereas Mac and Windows are not. I’m sure many people have been caught out by this where everything is fine until they deploy their codebase to a staging or production server, then they run into “file not found” errors due to referencing a filename with a different case.

If there is ever a chance that your project may be hosted on a case-sensitive server like Linux (quite common if you use a shared host), or if you’re releasing your codebase for public consumption where you obviously have no control over where it will be hosted (think blogCFC, Wordpress, FarCry etc) then you MUST test your codebase in a case-sensitive environment.

Now I used to be running Ubuntu (which is case-sensitive) but I’m currently on a Mac so my first thought was to create a Linux virtual machine using VMWare Fusion to test on. While this would be invaluable ongoing, I didn’t have the immediate time to setup and configure the VM, install ColdFusion and Apache and MySQL etc.

Luckily Mark gave me a nice and easy solution, at least for Mac users :)

**Note: Although the information below is Mac specific, I’m sure it is easily applied to Windows.

Essentially all you need is a thumbdrive (or any external harddive you may have lying around) which is big enough to hold your codebase. Likely your codebase will be under 50MB so I doubt space will be an issue. Thumbdrives are so cheap they literally give them away in cereal boxes, so you shouldn’t have a problem finding one.

Now you need to format the drive to be case sensitive using Mac’s “Disk Utility”. Remember that formatting the drive will completely wipe any existing data. Make sure you backup any data you wish to keep on this volume! Complete the following steps:

  • Connect your thumbdrive to your system
  • Open “Disk Utility”
  • Select the volume (thumbdrive) you want to format from the list on the left hand side
  • Choose “Mac OS Extended (Case-sensitive, Journaled) from the “Volume Format” drop down
  • Enter a name for your volume (this can be anything, I named mine “farcry5″ because that was the codebase I was testing
  • Click “Erase”

That’s it, in just a moment you’ll have a case-sensitive thumbdrive you can use to test any and all codebases on!

All you need to do now is setup a new vhost (or change an existing one) in Apache to read files from your thumbdrive. The following is what you can do to have a local site called farcry5.local:

  • Copy/move the project codebase to your thumbdrive
  • Make an entry in your hosts file for farcry5.local
  • Created a new vhost in Apache with the “DocumentRoot” pointing to your thumbdrive (obviously this means that the site will only work when the drive is attached!)
  • Created your database and ColdFusion datasource/mapping as you would normally do for any other project

Here’s a sample vhost for Apache, note the “DocumentRoot” points to my external Volume and I also added a “Directory” directive to grant permissions to that file location:

<VirtualHost *:80>
        ServerName farcry5.local
        ServerAdmin msharman@blahblahblah.com.au
        DocumentRoot /Volumes/farcry5/farcry/projects/mollio/www
        DirectoryIndex index.cfm
        Alias /webtop /Volumes/farcry5/farcry/core/webtop
        <Directory "/Volumes/farcry5/*">
                Options Indexes MultiViews
                AllowOverride None
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

Oh and for the curious, FarCry ran smoothly on my case-sensitive volume. No problems :)

2 Comments

Querying multiple databases within one cfquery

In discussing a possible caching solution at work a suggestion was made to use a secondary database (on the same server) to store some key application data. It’s not really important to describe why we wanted to do this, suffice to say that my concern was if and when the application would need to perform a SQL “JOIN” between the primary and secondary (caching) database as I wasn’t sure if it was technically possible within our environment (ColdFusion 8, MySQL).

I quickly mocked up a proof of concept and was pleased to see that this works fine with ColdFusion and MySQL. It looks as though <cfquery> simply wraps up your SQL and sends it to the database server for execution (as you’d probably expect), so this is really the ability of the database server rather than any specific ColdFusion engine.

The only thing you need to do is make sure that you explicitly qualify the references to your column and table names with the actual database name and very importantly make sure the database user (as defined in your cfquery datasource attribute) has access to both databases! Remember that you’re using a single ColdFusion datasource to talk to 2 different databases.

Here’s a code sample qualifying just the database and column names:

<cfquery name="qGetSomething" datasource="myDatasource">
SELECT	mydb1.Column1, mydb1.Column2, mydb2.Column3
FROM	mydb1.Table1 t1 INNER JOIN mydb2.Table2 t2
		ON t1.id = t2.id
</cfquery>

Here’s a code sample qualifying the database, table and column names:

<cfquery name="qGetSomething" datasource="myDatasource">
SELECT	mydb1.Table1.Column1, mydb1.Table1.Column2, mydb2.Table2.Column3
FROM	mydb1.Table1 t1 INNER JOIN mydb2.Table2 t2
		ON t1.id = t2.id
</cfquery>

If you get an error like the following back, you know you have a database user permission error :(

SELECT command denied to user 'mydbuser'@'localhost' for table 'Table2'
5 Comments

Installing a new FarCry 5 project – (Extended) Advanced Mode

There are several installation options for the latest version of FarCry (5.0.2) which makes things nice and flexible for the framework to be used by different people in a variety of setups.

The deployment configurations page has some easy to follow instructions for installing in “Standalone” mode. This is really the best option if you are in a shared environment where you may not have control over ColdFusion mappings, but also if you are looking to get up and running quickly (maybe you just want to evaluate the product etc).

For us we use FarCry for many applications, but in what would be considered an “Advanced” configuration mode (using FarCry 5+ parlance). Unfortunately it looks as though we may stray a little from the “Advanced” configuration which is the point of this tutorial.

The current advanced setup may be a little confusing to some. It doesn’t really list full details for the advanced mode, but still seems to require you to have FarCry running in the following directory structure (note that in the example below ‘farcry_5.0.2′ can really be called anything and is not a strict naming requirement, I like to use this as it is explicit as to which version I’m using):

  • /farcry_5.0.2
    • /core
    • /plugins
      • /farcrycms
    • /projects
      • /myproject1
      • /myproject2
    • /skeletons
      • /mollio

This is nice and easy as it gives you the ability to have only 1 ColdFusion mapping (/farcry pointing to your /farcry_5.0.2 directory) which all your projects can share (i.e. all projects would share the same farcry “core” and “plugins” codebase etc). It’s this structure where our setup starts to differ.

We typically have library directories to hold shared codebases and a completely separate location for our vhosts (projects or “web sites”). This is the main difference and means we have something like the following:

  • /libs/farcry_5.0.2
    • /core
    • /plugins
      • /farcrycms
    • /projects (note this is only needed for our installation, we won’t be hosting projects from here)
    • /skeletons (note this is only needed for our installation, we won’t need this in production)
  • /vhosts
    • /myproject1

Note: In actual fact our vhost setup is slightly different than what I’ve listed above, but this is easier to describe for the purposes of a tutorial.

This is an extremely flexible setup, but installing this way is a little tricky. I’ve done several installs for this configuration using the following steps:

Installation – Preparation

Is is assumed that your farcry files, as mentioned above, are in the following location (this location is of course an example of what you may have on a linux based machine, you could obviously use a different path like C:/libs/farcry_5.0.2):

  • /libs/farcry_5.0.2

It is also assumed that you want to install your project into the following location:

  • /vhosts/myproject

*Note: DO NOT actually create this project folder yet, we will move the folder to this location after the FarCry installation has completed.

Follow the following steps:

  1. Create a blank database. This can be called anything you want, typically something which mirrors your project name is a good idea
  2. Create a new datasource in ColdFusion Administrator and verify that it is connecting to your new database
  3. Create your project vhost (i.e. http://myproject.local) in your web server of choice (Apache or IIS etc)
    • Point the document root to ‘/vhosts/myproject/www’ (even though this actual location doesn’t exist yet!)
    • Make sure you have a ‘/webtop’ alias (this replaces the old ‘farcry’ alias for those familiar with prior versions of FarCry) pointing to /libs/farcry_5.0.2/core/webtop
  4. Create an entry in your hosts file so myproject.local is in use on 127.0.0.1 (for production you’d obviously use different settings!)
  5. Create a ‘/farcry’ ColdFusion mapping pointing to the directory which holds “core” (i.e. /libs/farcry_5.0.2)
  6. Create a ‘/farcry/projects/myproject’ ColdFusion mapping
    • mapping: /farcry/projects/myproject
    • path: /vhosts/myproject

*Note: You could get away with having a single ColdFusion mapping of /farcry/projects if all your projects existed under the same directory (i.e. /vhosts), otherwise create a projects mapping per project (e.g. /farcry/projects/myproject). I find it’s a good idea anyway to have a separate mapping per project.

Installation – Installing

To install FarCry we visit the ‘/webtop/install’ sub-directory off your project URL, e.g. http://myproject.local/webtop/install/.

You may be wondering how this works as we haven’t setup our physical project diretory yet, it works because of the web mapping (alias/virtual directory) of ‘/webtop’ which points directly to /farcry_5.0.2/core/webtop/install.

Ok we’re almost there! If everything is going well so far and the stars have aligned you’ll see the FarCry installation screen.

The important value on this page is “Project Folder Name”. This should be “myproject” (i.e. what will become the physical name of your project directory, the same name as we added in our vhost).

The 2nd step allows you to enter your ColdFusion datasource and database type:

On the 3rd step you must choose a skeleton to install from. Just use the default ‘mollio’:

The 4th step is for plugins, for most cases leave the default which is probably ‘farcry’ and ‘farcry greybox’:

The 5th step is important as the default is “Sub-Directory”. You have to change this to the last option “Advanced Configuration”:

Step 6 is a confirmation step, nothing to do here except “INSTALL NOW”:

After hitting “INSTALL NOW” FarCry will go off and do its magic:

When the installation is complete and you can see the final screen FarCry will have successfully installed your project under the /libs/farcry_5.0.2/projects/myproject directory.

**Important** BEFORE you click the “VIEW SITE” or “LOGIN TO FARCY WEBTOP” buttons you must move the project directory to where you’ve specified in your vhost (i.e. move ‘myproject’ from ‘farcry_5.0.2/projects/myproject’ to ‘/vhosts/myproject’).

Once you’ve moved your project directory, you can click the “Visit Site” button and/or “Login to the FarCry Webtop” and you’re ready to roll :)

Hopefully that helps people trying to install FarCry in a slightly different configuration.

No Comments