Documentation 2.x and 3.x

Plugin configuration and translations options

Often you plugin needs some configuration options and translations. Read here to learn how to implement them.

See Simple slideshow plugin as an example.

1 Step - create a plugin.

Read examples in other sections how to write a plugin in general. Your plugin should be already installed to proceed to next step.

2. Step - create required parameter gruops

Open administration panel Developer -> Modules config tab. Here is an administration panel of all system translations and configuration options.

Select your new plugin on the left. Now on the right you can create parameter groups.

Usually you need several groups:

 

  • options,
  • admin_translations,
  • translations.

 

You can name them in any way you like. But everybody will understand you better if you will try to fit into these and some additional groups.

Each parameters group consists of three values:

 

  • Name - name your group anyway you like
  • Key - text string how you will refer to this group in your code. Usually the same as name, just lowercase and with underscores instead of spaces.
  • Admin -  if checked, this group will be not accessible from Standard -> Configuration tab.

3. Step - create required configuration options and translations

Now press yellow icon on each of your groups and create required parameters. There are following types of parameters:

  • String - some string value or administration panel translation
  • Integer - usually used for plugin configuration
  • Boolean - usually used for plugin configuration
  • Textarea - for plain text information
  • Wysiwyg - for rich text formating
  • String / Textarea / Wysiwyg languages - used for trnalsations. ImpressPages will automatically create as much input fields as needed to translate to all registered languages.

You can create any number of any type of parameters in any group. It is up to you.

4 Step - use your configuration options / translations in plugin

To get any value, use following code. Use it anywhere in your code to make decisions or output text:

<?php 
global $parametersMod;
echo $parametersMod->getValue('module_group_key', 'module_key', 'parameter_group_key', 'parameter_key'); //will output configuration value. If it is a language field, the value will be taken according to current page language.
?>

All textual information that appear in administration panel, should be stored in String / Textarea / Wysiwyg parameters.

Any textual information in public area of the website, should be stored in String languages / Textarea languages / Wysiwyg languages parameters.

Integrate created parameters to installation script

Go to Developer -> Modules exp/imp tab. Here you can export and import all or some particular configuration / translations values of your system.

Select your new module here and press export. Save exported file as 'config.php' in install directory of your plugin.

That's all. Now on installation all configuration values will be imported by default.

ImpressPages support many languages. So you can include translations for all supported languages. Just in the same way create required parameter files and save them in the same install folder with following naming pattern:

  • translations.public.xx.php //for public area translations. Replace xx to language code
  • translations.administrator.xx.php //for administration area translations. Replace xx to language code

You can add any number of supported languages. 'config.php' will be always imported and should contain all configuration options and translations. Translations to specific languages will be included if available on top of 'config.php' values.

Usually translations.public.xx.php files have only String / Textaera / Wysiwyg parameters. While translations.administrator.xx.php files have only String languages / Textarea languages / Wysiwyg languages parameters.

Integer and Boolean appear only in config.php file.

See Simple slideshow plugin as an example.

Write a comment

You must be logged in to comment.