>, Tutorials>Website constants

Website constants

Infradox XS websites are template driven. The templates use constants to output text depending on the active locale (user interface language). But the use of constants also lets you edit texts in a single place, automatically updating every page it’s used on. The constants files are centrally stored, i.e. all Infradox XS websites use the same constants files. You can change the values for these locales by creating a local copy of one or more of these files (a copy is automatically created if you save a constants file). Note that the constants can also be used in your custom templates. This article describes how you can create and modify a local copy of the constants files.

Changing the constants

Go to Site configuration and click Constants. Then select the locale that you want to change in the dropdown box at the top. The list at the top of the page shows all the constants files (you may need to scroll inside the boxes to see all the files). The list at the bottom of the page shows the changed constants files.

Please read the itemised list in the paragraph below before making changes.

  • To create a new local copy for your changes, click on the file name in the box at the box (unmodified versions) to open the edit dialog. Make your changes and click save at the bottom. A local copy will be created if it didn’t already exist. Your local copy will be overwritten if it did already exist.
  • To make changes to a local copy of a constants file (i.e. the version of the file that was previously modified), click its name in the list at the bottom to open the edit dialog. When you are done, click the save button.
  • To restore the original constants file, click the delete button on the right of the list with local copies.

Finding the file that has a text that you want to change

The constants are organised in many separate text files. To find the file that has a text that you want to change, first select a locale in the drop down. The list will show all the constants files and the list underneath it will show the constants files that have been modified (see below screen shot). To find the files that have the constant(s) that you want to change, click on the Find constant button.

A search dialog will open where you can enter the text that you’re looking for. In the below screen shot you can see the found files after a search for “download”. The dialog lists the file names (the number indicates how many times your search term was found in the file), and for each file it lists the constant that is found. You can search for both the name of constants and the value of constants.

If you want to open a constants file, then click on its file name in the search dialog. If a local copy (modified version) exists, then that’s the file that will be opened for editing. If not, then the original constants file will be opened for editing. The below screen shot shows the contents of the file after clicking on its file name.

File manager

You can use the Website File manager to quickly view and edit the modified constants files. The modified files are stored in the folder /config. For further information, please read the article Using the Website File manager.

Important

Changing constants with the built-in editor is simple, but there are few rules that you need to take into account:

  • Constants files have name=value pairs on each line. A single line may have only one constant
  • A constant must use the format name=value
    For example cClosebutton=Close – where cClosebutton represents the name, and Closerepresents the value – you may only change the value part
  • A constant (i.e. a line in the file) may have only one = character
  • A constant may not have quotes (“)
  • You should not change the name part of a constant (see above)
  • You should not remove constants from the file
  • You should not add new constant names to any of the files, with the exception of the file custom.txt
  • The changed value part preferably uses a similar length. You will have to test your changes carefully to make sure that your changes do not break the page layout. You may have to create custom css for certain elements if the changed version of a constant’s value is longer or shorter than the original value.
  • The constants files may have constants that are no longer used, but that are still in there for backward compatibility.
  • The constants files may have constants that can be changed in other places in backoffice. Please check before you make a change.
  • Some contant values have a code between square brackets (e.g. [cart] or [count]). These should stay, values are automatically replaced by configured values. E.g. [cart] may be replaced with Basket if you have configured that to be the preferred term.
  • The value of a constant may start with a * (asterisk) to indicate that the value contains a replace tag (between square brackets). The * will automatically be removed and the tags will be replaced. E.g. cSomemessage=*Call us on [phone] for information about your [cart].
    If a constant value has tags but doesn’t start with a *, then the tags will not be replaced.
  • It is recommended to not create a local copy of a constants file if you didn’t change anything in that file.
  • Constants are cached in each web API’s instance. If you make changes, the current instance of the web API will automatically flush its internal cache and it will try to unload other instances that may be in memory. However, sometimes it is not possible to unload other instances. If you don’t see your changes on the client facing website then try to view your changes using another browser or another computer. All instances are automatically recycled every x-minutes so worst case you’ll have to wait until this event has occurred on the server.
  • If you create local copies of constants files, any changes that may be introduced by an XS update are automatically added by the Infradox Update software.
  • If you run into problems, simply (temporarily) remove your local copy which will automatically restore the original file.
2019-01-04T16:48:54+02:00 February 12th, 2017|Categories: Configuration, Tutorials|Tags: , , , , |