[Coldbox-3.5.0] most efficient way for dynamic footer


I have a footer with a database driven content, that show last three post entries. The footer is the same on every page.

What’s the most efficient way to show the footer on every page?

There are several ways you can do this efficiently. Here are three:

1 - Using Interceptors: Create an interceptor to query the DB using the preProcess interception point; within your layout, access your query to do your thing.
2 - Using onRequestStart event: Almost the same as #1 - use the onRequestStart event (by convention its handlers/main.cfc – must be enabled in the ColdBox config). Only difference here is the location of the query request.
3 - Using view helpers: Use a view and view helper; Within your layout render your footer renderView(‘footer’) and create a View Helper with your query. A view helper is a file named the same as your view with Helper at the end. It will be executed before your view.

A View helper is probably the most efficient implementation for what you seek. Choosing that route will ensure your query is not executed for any requests that don’t actually use the footer.

Hope this helps.


I didn’t know view helper. Many thanks!!!

So I should only insert a in my htmlhelper? I use orm in my application, this will work?

how can I set datasource?

if I try does not work…