Tag Archives: ColdFusion

02Sep/13

Dynamic creation of variables, based upon a database table

The other day, as I fiddled with my weekend project, I stumbled into a concept that I had not thought of previously.  I was looking to make it as easy as possible to make the app multi-lingual.  In trying to separate the application from the translations, I came up with an interesting technique.

 

 

When you select a language, it loads records associated with your selected language.  They have the attributes of “name” and “value”.  It loops through the returned records and uses “name” as the variable name and “value” as the value.  When you add a new record to the table, it automagically adds the new variable.

Dynamic Variables - DB Schema

Dynamic Variables - DB Content

Dynamic Variables - App Output EN

Dynamic Variables - App Output SP

Dynamic Variables - App Output LA

As you can see, addition of new translations pretty easy.  Have a thought on the technique? Feel free to leave a comment or drop me a line.

16Dec/12

How to handle pagination in ColdFusion

So, you have a task where you are supposed to display X items but only Y items per page and only link to Z pages at any one time?  This can be a fairly complex task.  I figured that I would offer my ~80 line solution to the problem.

Here’s an example of what the output should look like.