Good news for children everywhere… Tree Inspector now alerts you when you are with the wrong parent!

Ever thought your navigation node was appearing under the wrong parent node?

Well the updated Tree Inspector helps ease your anxiety, take a look at the image below.

In the case above you will see that the footer nodes parentid does not match the utility nodes objectid. There are two possible causes for this and I will explain them and the fixes below.

  1. The footer node is underneath the wrong parent; in this case you would simply update the nLeft and nRight (as normal) so that the node jumps underneath the correct parent node.
  2. The footer node is underneath the correct parent, but for some reason the parentid in the database in wrong; you would need to manually update the nested_tree_objects table so that the footer nodes parentid is the same as the utily nodes objectid.

Have a shot at using this release and if you have any thoughts / improvements please post them here.

Now and then when building a custom farcry object you might get the error ‘Element [insert object name] is undefined in a CFML structure referenced as part of an expression.’ upon accessing one of its methods by using the application scoped path eg:

createObject("component",application.types['insert type name here'].typepath)

Basically, this means that during the initialisation of the farcry application there was some sort of syntax error in the farcry object and was not able to be referenced in the application scope.

The simplest way to debug this is to make a small test file, put it into the webroot and call the object directly eg:

<cfset o = createObject("component","farcry.projects.projectname.packages.types.objectname") />
<cfdump var="#o#" />

Run the test file and it will try and create the farcry object and crash letting you know where the problem lies. All you have to do is fix the problem until you are able to run your test file without it crashing, then update the farcry application and boomshanka, all will return to a perfect state of harmony.

At the moment jQuery is our javascript framework of choice – it is straight forward to use and you can create complex effects/functions with only the basic of knowledge. Although like many coding languages your source can quickly become bloated and start affecting the performance of your application. Luckily while reading my daily new feeds I found a great post written by Samer Kamel Draidi (originally by Jon Hobbs-Smith) which details 25 excellent tips to improve the use of jQuery.

The article ‘Improve your jQuery – 25 excellent tips‘ has many great tips to increase speed and generally improve how you code using jQuery and I feel it is a must read… so check it out.

Recently, I’ve discovered that some of the Firefox version 2 (in particular 2.0.0.20 on Window Vista) has an error in the mime type settings. Reasons for this is because when I uploaded a PDF document (using cffile tag) via the Firefox browser the mime type returns from the browser was ‘text/html’ instead of ‘application/pdf’. Patrick van Bergen wrote a detailed article about this issue and has concluded that this occurs due to the incorrectly configured mimetype.rdf file located in the Firefox profile folder. There’s no common solution for this issue so far and the best we can do is to perform checks for both the mime type and the file extension to determine the content of the file.

The filter form on the top of the object admin page inherits the default properties, this can be problematic especially when you only want something to be display only.

When a property is set to display only, you are unable to filter by it.

To fix this modify the custom admin file as below.

<cfset stFilterMetaData = structNew() />
<cfset stFilterMetaData.thehiddenproperty.ftDisplayOnly= "false" />

<!--- set up page header --->
<admin :header title="News" />

<ft :o bjectadmin  typename="dmNews"
permissionset="news"
title="#application.adminBundle[session.dmProfile.locale].newsAdministration#"
columnList="title,catnews,publishdate,datetimelastUpdated"
sortableColumns="title,publishdate,datetimelastUpdated"
lFilterFields="title,source"
stFilterMetaData="#stFilterMetaData#"
sqlorderby="publishdate desc"
plugin="farcrycms"
module="/dmNews.cfm" />

read more at http://docs.farcrycms.org/display/FCDEV40/Formtools+Object+Admin

The other day i was having an issue with a button which had a movie clip layered on top of it. I assumed that the movieclip on top of the button would disable the button mouse events but after running my application, the button was still firing an onRelease event (even though you could not see it on stage). After a bit of research, i discovered that setting the ‘visible’ property to false on a button/movieclip completely disables the mouse events for the button/movieclip, as well as hiding it from the stage. I’m finding this very useful for situations where i would like to dynamically enable or disable the mouse events of a button/movieclip.

No… not global warming.

Developing on your local environment is quite often very different to what is actually running at your hosts end. I am not going to tell you how to get around the issues with different combinations of CF, database server and web server but instead, here is a little script that you can upload to your host and see what they are running compared to yourself if you run into any ‘environment’ issues. Hopefully armed with this info and google you can find someone who has the same issue, goodluck:

<cfquery name="q" datasource="#application.dsn#">
	SELECT version() AS MYSQLversionNo
</cfquery>
<cfoutput>
	<html>
		<style type="text/css">
			body{
				font-family: verdana;
			}
		</style>
		<body>
			<h2>CF - #server.coldfusion.PRODUCTVERSION#</h2>
			<h2>MYSQL - #q.MYSQLversionNo#</h2>
			<h2>WEBSERVER - #CGI.SERVER_SOFTWARE#</h2>
		</body>
	</html>
</cfoutput>
 

To ensure a successful execution of your schedule task, always include a small statement at the end of the script such as

<cfoutput>Script has been successfully executed</cfoutput>

This is because when Coldfusion executes the schedule task it wraps the script in a cfsavecontent tag and checks the length of the cfsavecontent variable. If the variable string has no length it errors and when Coldfusion server catches this error, it stops the execution of the schedule task.

An easy way to check if your schedule task is running correctly, go to Farcry Admin schedule task and select the View option for one of the schedule task. This will opens up a new window and the script is executed. If no error is produced, your script is working!

Pagination is a pretty normal approach these days to presenting large amounts of data to a user in easy to digest amounts. Instead of presenting a ridiculously long list of data with hundreds, maybe thousands of rows, the obvious choice is to break it into sizable chunks and then go from page to page, sorry if this sounds obvious.

There are many many ways to achieve the result of pagination but probably the most common way in Coldfusion is to execute a query, then using cfloop, present the data using the startrow and endrow attributes and present a maximum amount of rows per view, say 10.  The problem here is that if you have your pagination working so that every time you move from one page of results to the next, it refreshes the page and re-executes the same query, well, if there are a lot of results, that becomes a lot of unnecessary processing and data transfer between the coldfusion server and the database server. Think of it like this, if each time you are running a query and 1 mb of data has to be transferred it would work something (very roughly) like this:

CF template is executed > CF makes a request to the SQL server via the network > SQL server executes the query and returns the data via the network > CF puts the data returned into memory > CF executes the rest of the template to present the data.

If you have a busy site and this same query is being executed over and over, dragging this large chunk of data across a network everytime then expect your site to run very badly. This is where query caching comes into play and makes everything slinky and sexy….

The geniuses at the Coldfusion factory thought about this very issue eons ago and implemented a nice and simple way of caching repeated queries by introducing an attribute for the CFQUERY tag called ‘cachedwithin‘. Basically, all you need to do is create a time span and add it to this attribute like so:

<cfquery name="qReturn" datasource="#application.dsn#" cachedwithin="#CreateTimeSpan(0,0,6,0)#">
BIG NASTY QUERY
</cfquery>

The above would make this query cache in the servers memory for 6 minutes before it went and got a fresh copy. So instead of going through all the time waiting for a SQL server to execute a complicated query and return a giant chunk of data, it’s already there in memory waiting for you to use! how cool (I mean sexy) is that!

There is one more thing to add… what if the query you are caching is set to only update every 24 hours but you need to purge it to update the results to appear in this recordset now! Well luckily there is a bit of a hack to get around this, you see while the people in CF land made it easy to cache a query, there is nothing really obvious to purge that query from cache. The only way to do this is to execute a query of the same name and same SQL syntax and set the time span to -1 second, that’s it, pretty easy.

<!--- reset nav cache --->
<cfquery name="qReturn" datasource="#application.dsn#" cachedwithin="#CreateTimeSpan(0,0,0,-1)#">
BIG NASTY QUERY
</cfquery>

Now the next time your template executes it will grab a fresh set of that data and keep it in cache for whatever timespan you desire,  SEXY!

I use the actionscript Tween class a lot for dynamically applying tweens to my Movie Clips at run time. I came across a problem, the other day, where a text field was not responding to a tween that I applied to it’s parent Movie Clip (in this case changing it’s alpha). After a bit of research, I found out that you HAVE to embed your fonts if you wish to apply a rotate or alpha tween on a Movie Clip that contains a text field. Simply select, the text field in question, click embed from the property menu and the text field will respond to all tweens applied to it’s parent.