FILE Binding

Skip to end of metadata
Go to start of metadata


What is the @FILE Binding?

The @FILE Binding returns the contents of any specified file.

Syntax

@FILE file_path

Binds the variable to a file, where file_path is the path and name of the file. The return value is a string containing the content of the file. The file path is the absolute path from the root of the server or your particular installation.

The @FILE command is very useful in cases where we might want to generate data that's available in file. By using the || and == characters as a delimiter we could interface with any external database application.

Usage

For example: Let's say we have a text file called headline_news.txt that is external to our database system. This file is constantly being updated with up-to-the-minute news items by another external system. We want to display these news items on our website for our visitors to see. How can we do that?

First, we might create a new Template Variable. We then add the @FILE command inside the default value of the TV. This will point to where the headline_news.txt is located in our example. Our default value might look like this:

@FILE assets/news/headline_news.txt

Let's say each headline in the headline_news.txt file is separated by a new-line (lf or \n) character. We can use the Delimiter render to separate each item and display them one at a time. Our fields will look like this:

Unable to render embedded object: File (filebinding.png) not found.

And viola! We have our dynamically rendering @FILE binding.

See Also

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.