Prototype/scriptaculous issue with Sortable.create()

I’ve been doing some custom sorting within FarCry using the prototype/scriptaculous libraries as they already exist in the FarCry framework by default.

I was having trouble getting the Sortable.create() to work properly and the main docs site for scriptaculous seems severely lacking in examples. Basically the “sorting” action was happening fine but no event was being fired “onUpdate”. No exception was being thrown, just that nothing was happening after the drag/drop.

The solution came from google (where else?) on the rubyonrails groups thanks to a fellow named Chris.

Straight from the board:

Wait, read that again. Are you serious?

Yep…you have to split your “id” value with a string, then an underscore followed by an integer. This is truly the dumbest thing I’ve found in a while. Hall of famer for sure.

Just posting here to help anyone else who spends more time than necessary getting this (simple) task working.

No Comments

Setting application variables in FarCry

I just thought I’d write up some quick thoughts on setting application scoped variables in FarCry as it occured to me that it could be a little confusing to non-FarCry developers.

It doesn’t really matter which framework you use, you can theoretically set you application variables anywhere you want, but ideally you want to follow some sort of methodology and consistency both with the rest of your development team and of course the framework you happen to be using.

FarCry has (somewhat) recently added a “farcryConstructor.cfm” inside the project webroot (www). A quick peek inside suggests that this is where application vars are set, this is re-inforced by checking Application.cfc which has a bascially empty OnApplicationStart() in terms of setting project application vars.

Sample of farcryConstructor.cfm:

There is also the /config directory which has been in existence for several versions and contains, you guessed it, “configuration” files. Namely:

  • _serverSpecificRequestScope.cfm
  • _serverSpecificVars.cfm
  • _serverSpecificVarsAfterInit.cfm

So where do you add your custom project application vars? The options we have so far are:

  • www/farcryConstuctor.cfm
  • www/Application.cfc
  • config/_serverSpecificxxx.cfm

Well farcryConstructor.cfm could seem like an ideal place, after all it’s the “constructor”. But it is generated from the installation routine and as such ignores any custom variables which are set inside it. So steer clear of this one.

OnApplicationStart() would also be a logical place inside Application.cfc. After all that’s probably where all your configuration happens in non-framework applications. This will indeed work as expected, but it’s not really the ideal place for your project config information.

It’s probably best to follow the “FarCry way” of doing things which is to utilise the files inside your /config directory. This should be the first place anyone in your development team goes to look for any custom project properties or application scoped variables.

Let’s look at the 3 /config files:

_serverSpecificRequestScope.cfm
This file is run after /core/tags/farcry/_requestScope.cfm
It enables us to both override the default farcry request scope variables and also add our own

_serverSpecificVars.cfm
THIS WILL BE INCLUDED BEFORE THE FARCRY INIT IS RUN BUT ONLY ON APPLICATION INITIALISATION.

_serverSpecificVarsAfterInit.cfm
THIS WILL BE INCLUDED AFTER THE FARCRY INIT HAS BEEN RUN BUT ONLY ON APPLICATION INITIALISATION.

I would therefore use _serverSpecificVars.cfm for all your application scoped variables as it is run once on application initialisation. If you need to make a change here you need to update the application.

I’d use _serverSpecificRequestScope.cfm for all your request scoped variables. This template is basically like OnRequestStart() in Application.cfc, i.e. it is executed on each page request.

Hope that helps some people :)

No Comments

Setting the sort order for custom admin items in FarCry

I’ve wanted to be able to control the sort order of menu and menuitems in the customadmin.xml (or equivalent) file for quite a while but hadn’t found how to do it. Only today did I find the ability, I believe it’s a FarCry 5+ feature which was why I didn’t see it before.

The answer is simple, just add a “sequence” attribute to your menu or menuitem tag:

You can read more cool things you can do with your custom objectadmin on the FarCry docs site.

No Comments

Changing the sort order of FarCry categories/keywords

Categorising content with keywords (or “tags”) is a well known concept these days and it’s good to know that FarCry has had this ability long before it became cool!

I’m using categories to group content for a custom type but I needed to allow the editors to sort these categories and not rely on the alphabetical order of the category etc.

Luckily in FarCry categories use the nested tree object model (exactly like the navigation tree) so sorting is absolutely possible. But has it been built into the UI?

I first went to the original categories view in the webtop (Manage Keywords) to see if the UI allowed for sorting. It didn’t. But then I went to the flex equivalent “Manage Keywords (flex)” and was pleased to see that you can simply drag/drop your categories around much like you can in the “Site” tab for navigation elements.

This funtionality is available in at least FarCry 5.1.4

1 Comment

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