You are here:
ColdFusion - a middleware web server technology from Adobe ColdFusion - a middleware web server technology from Adobe

cfdocumentitem footer and variables scoping - attributes scope

I was recently working with the cfdocoumentitem and cfcdocument tags and to produce a PDF for a client. In the footer of the PDF document, I needed to output the page x of x statement, along with the name of the particular book / title I was working with. I had the book data available to me inside a "local" scoped struct, inside the ColdFusion CFC method I was working in, but could not get this to output inside the footer tag. After a little bit of googling I found the solution to this problem.

The solution was fairly simple, but involves passing the struct of data that you want available to into the tag itself. E.g.

<cfset local.stbook = { price="9.99" publishername="My Publisher" title="my book" type="footer" } />
<cfdocumentitem attributecollection="#local.stBook#">
<cfdump var="#attributes#" />

Once the data is passed into the tag itself, it's then available to the tag inside the "attributes" collection. The same principle as a custom tag. Works like a charm :-)

Solution found on StackOverflow.