Blog

The Global View Helper

Luis Majano February 17, 2015

Spread the word

Luis Majano

February 17, 2015

Spread the word


Share your thoughts

Since the early ColdBox 2 versions we had the ability to declare helpers for our layouts and views by creating a file right next to the view and adding the suffix Helper to it.  This would allow the framework to bind the two templates together at run-time.  This is a great way to provide further separation by convention.  However, there was no way to affect layouts and views globally.  You only had the global application helper which injected functions and variables to handlers, layouts and views.

In ColdBox 4 you have a setting viewsHelper which is a template that will be injected and bonded to any layout/view that is rendered. This means that finally you have a template that can be globally available to any view/layout in your system.  This is a great way for you to add your own functions for things like i18n, localization, and much more.

coldbox = {
    viewsHelper = "includes/helpers/ViewHelper.cfm"
};

Enjoy!

Add Your Comment

Recent Entries

Into the Box is Going Online, Register Now!

Into the Box is Going Online, Register Now!

Dive into the Future of Web Development with Into the Box 2024 - now going global and online! No matter where you are, you're invited to join us for an amazing and enriching two-day experience on May 16th and 17th, packed with groundbreaking insights, expert sessions, and game-changing announcements.

Maria Jose Herrera
Maria Jose Herrera
May 01, 2024
Into the Box 2024: Your Gateway to the Future of Tech!

Into the Box 2024: Your Gateway to the Future of Tech!

Are you ready to advance your coding skills? The future of Modern Web Development awaits at Into the Box 2024, and we're thrilled to announce that due to high demand, we're extending our Early Bird pricing for an additional week!

Maria Jose Herrera
Maria Jose Herrera
April 26, 2024