Документация InstantCMS

для администраторов и разработчиков

Инструменты пользователя

Инструменты сайта


Creating Template Options

If necessary, each template can have a set of options. Suppose, our template is called «my_best_template». Do the following to create a form of options:

  • Create the /templates/my_best_template/options.form.php php file;
  • Inside it, define a class for the options form whose title is formed according to the formTemplateTitleTemplateOptions principle, in our case, it will be called formMyBestTemplateTemplateOptions;
  • Describe the form fields.

Once the form is created, a link to the settings page will automatically appear on the “Interface” tab in the site's General Settings.

:!: Pay attention! The form class should be always defined as formTemplateOptions for InstantCMS version 2.4.0 and older. I.e. the title is identical for all templates.

In a custom template, you can (optionally) describe your own form output template. As for our «my_best_template» template title, create a file under the path /templates/my_best_template/controllers/admin/settings_theme.tpl.php.

Its minimum contents can be as follows:

<h1><?php echo LANG_CP_SETTINGS_TEMPLATE_OPTIONS; ?>: <span><?php echo $template_name; ?></span></h1>
    $this->addBreadcrumb(LANG_CP_SECTION_SETTINGS, $this->href_to('settings'));
    $this->renderForm($form, $options, array(
        'action' => '',
        'method' => 'post'
    ), $errors);

All template settings are saved in the YAML-format file located under the path /system/config/theme_TEMPLATE-TITLE.yml, i.e. it is the /system/config/theme_my_best_template.yml file in our case.

Back to Section Contents

en/dev/templates/options.txt · Последнее изменение: 19.03.2017 00:18 — murlysja