The Custom Text plugin displays text from system language files as specified by the {exp:custom_text} tag. It also allows the use of custom language files to contain often used text.
Example Usage
This EE Code:
{exp:custom_text string="search_module_name" file="search"}
Returns this text:
Search
This EE Code:
{exp:custom_text file="search"}
{exp:custom_text string="search_module_name"}
{exp:custom_text string="search_no_result"}
Returns this text:
Search
Your search did not return any results.
This EE Code:
{exp:custom_text file="search"}
{exp:custom_text file="member"}
{exp:custom_text string="search_no_result"}
{exp:custom_text string="query_module_name" file="query"}
{exp:custom_text string="choose_new_un"}
Returns this text:
Your search did not return any results.
Query
Please choose a new username
Parameters
string- The string parameter tells the Custom Fields plugin to display text that corresponds to the provided parameter.
If a file parameter is given in the same tag {exp:custom_text string=“string” file=“file”}, that file will be used to locate the string. If no file parameter is given in a tag {exp:custom_text string=“string”}, the Custom Fields plugin will see if the string is available from an already loaded file. If the string cannot be located, the string itself will be displayed.
file- The file parameter tells the Custom Fields plugin to load a language file that corresponds to the provided parameter.
Individual {exp:custom_text file=“file”} tags should be loaded as early in the template as possible, as their values will only be available to subsequent {exp:custom_text string=“string”} tags.
The file parameter should contain the name of the module, plugin, or extension from which you want to use strings. It should be provided exactly as it appears in the languages folder (without the prefix “lang.” or suffix ”.php”). If no file parameter is given anywhere in the template, the plugin will attempt to use the “lang.my_custom_text.php” file.
The user’s default language is always used (or if the user is anonymous, the system’s default language is used).
If more than one file contains the same string key, unexpected results may occur. If this happens, be sure to specify the exact file to use with a {exp:custom_text string=“string” file=“file”} tag.
{exp:custom_text} tags can be placed in different levels within embedded templates. {exp:custom_text string=“string”} tags should work as long as an {exp:custom_text file=“file”} tag is somewhere upstream.
Custom Language Files
This most useful aspect of this plugin is that it can be used to create custom language files. Simply place the included “lang.my_custom_text.php” file in your language folders.
(my_custom_text can be any string, though to avoid conflicting with other files you should probably use a prefix e.g. mydomain_custom_text or myname_custom_text. Additionally, for best results be sure the string keys within the language file are unique, again use a prefix e.g. mydomain_string1, mydomain_string2, etc. Language file keys must be entirely lowercase.)
Versions
v0.2.0: First Release.
v0.3.0: If no file parameter is given and the string cannot be loaded from memory, the plugin will check for a “lang.my_custom_text.php” file. (This file is now included in the package by default.)
