|Getting StartedHelpful ResourcesAsk questions on the Help ForumRead the User GuideBrowse the Reference DocumentationSubscribe to the Helix Mailing ListLearning Helix|
Helix uses codebehind files to provide functions that are ready to be called on the server once a page has loaded in the browser. A codebehind file is simply a collection of functions that are specific to a single page in a Helix application. Codebehind files are optional and will be loaded by Helix if they exist in the page folder.
Creating Codebehind Files
If you need to use codebehind functions for a page in your application, add a file in the page folder with the same name as the page, but with a ".cb.php" extension. For example, you can add a codebehind file for a page named test-page by creating a file named test-page.cb.php in the test-page folder. Once the codebehind file exists in the page folder, it will be automatically loaded by Helix when that page is requested.
Using Codebehind Files
Codebehind functions for a page are loaded every time the page is requested, every time an AJAX call is made from the browser where the page is loaded, and every time a function argument is called using the "f" parameter in a request. The codebehind file should only contain a list of functions that are specific to the page.
See the code below for an example of how to define a function in a codebehind file and use it in several different ways:
The following code shows how to call a codebehind function from within the markup file.
The following code shows how to call a codebehind function on the server when a button is clicked in the browser.