Let a thousand I.C.E. APIs bloom!

Create New Label

For multi-lingual sites, I.C.E. CMS uses Labels assigned to Languages to implement the mult-language functionality in Containers. A label is a piece of text in a specific language. By inserting labels in your code, you allow site users to switch languages on the fly by simply changing their default Language. Any static text in your your HTML code can be a Label. Example labels are:

  • Please fill in all the required fields!
  • Name:
  • E-mail:
  • Send

Note: Only Containers can contain Labels, so it's good practice to use Containers and include them in your Channels rather than placing HTML code directly in a Channel's Index Template Code or Page Template Code fields.

 

Create New Label

Select Label in the Create drop-down box. Enter the Label content in the Translation Label field. Select the Container that the Label is for and select the Language of the Label. Then enter a Rank starting from 1. The Rank determines the order in the Container that the Label appears. Set the Status to Active and click the Save button.

 

Using Labels in Containers

To use Labels in your site's Containers, you use the Translate widget (translate.cfm in the widgets folder). The translate widget takes three parameters: container, site_id and site_language_id.

In a Container's Code field, use the following code to retrieve the labels for that container:

Example Code:

<cfmodule template="../../../widgets/translate.cfm" container="[CONTAINER_NAME].cfm" site_id="#session.my_site_id#" site_language_id="#session.my_language_id#">

 

The example code above retrieves all the Labels for the container specified in the container= parameter in the site viewer's default language.  The Labels are returned as a comma separated list in a variable called session.label. You should escape any commas in the Label text itself when creating Labels.

You can temporarily dump the labels returned by the code above using the code below:

Example Code:

<cfdump var="#session.label#">

 

To output the retrieved Labels within the Container's Code field, use: 

Example Code:

<cfoutput>
#listget(session.label,1)#
</cfoutput>

The number 1 in the code above means the 1st Label in the list of Labels returned. To get the 2nd Label change the number 1 to 2:

Example Code:

<cfoutput>
#listget(session.label,2)#
</cfoutput>

 

Note: Ensure that the Label, you want to display has been created and that the same Label exists in all Site Languages.



DEMO (Beta)

Don't take our word for it. Try Lingxia 273 I.C.E. content managent system now: (Contact us to access the demo with Admin privileges)

E-mail:


Password:


DOWNLOAD IT!