CFWheels passing looping data to a specific partial.
So today I was digging around with the includePartial function of CFWheels and my favourite usage of it is:
#includePartial(somedata)# //somedata is the results of a findAll or similar
My problem was that I wanted to do this, but not repeat myself over multiple partials around the site. So I did some digging and found out that include partial has 3 undocumented arguments that get overwritten in the previous example (depending on what kind of variable somedata is), but not if you do:
These 3 arguments are; query, object and objects. These are set to the query/object/array that you pass through in the ‘somedata’ argument. So for example given that
is called, somedata is an array of objects and the result is that the partial _objectName.cfm is rendered for every object in the array. We can get exactly the same effect by calling:
This means that you can now store global partials that can be called from anywhere in your site (if you also want global dataFunctions put the dataFunction in Controller.cfc).