Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,113 of 9,113 pages
About the help in other languages
All help pages

Giving a theme its own settings file

Give a theme its own settings file (mytheme.ini) with documented defaults, read it from templates with ezini() and from PHP with eZINI, and let installations override it safely.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/designers/extensions/your-own-ini-file.md

On this page

Giving a theme its own settings file

This page is for designers who want options in their theme (a color scheme, the number of teasers on the front page, Open Graph defaults) without asking users to edit templates.

A real example

cjw_themes_jumper ships settings/cjw_jumper.ini.append.php. Its 0.1.2 release, for example, reads the classes treated as articles for Open Graph from cjw_jumper.ini [OpenGraph] ArticleClasses.

Step by step

  1. Create extension/mytheme/settings/mytheme.ini.append.php with a documented block:

    <?php /* #?ini charset="utf-8"?
    
    [FrontPage]
    # How many teasers the front page shows (a whole number from 1 to 12)
    TeaserCount=6
    
    */ ?>

    An installation without your theme has no mytheme.ini at all, so the append file is the only place the defaults live. Comment every setting.

  2. Read it in a template with the ezini operator:

    {def $count = ezini( 'FrontPage', 'TeaserCount', 'mytheme.ini' )}

    See The ezini operator.

  3. Read it in PHP (an operator or a module of the theme):

    $count = (int) eZINI::instance( 'mytheme.ini' )->variable( 'FrontPage', 'TeaserCount' );
  4. Clear the INI cache and check:

    php bin/php/ezcache.php --clear-tag=ini --allow-root-user
    ./console exp:ini where mytheme.ini/FrontPage/TeaserCount --allow-root-user
  5. Tell users in the README how to override it: in settings/override/mytheme.ini.append.php, never in the theme's own file (an update would overwrite it). A siteaccess folder does not work for a key the theme's file sets, because the settings/ of the extensions in ActiveExtensions[] are read after the siteaccess settings and win.

Good practice

  • Validate what you read: cast numbers, compare against a list of allowed values, fall back to the default.
  • Never read secrets from a theme's settings file; secrets belong to the installation's override folder.
  • When you rename or remove a setting, keep reading the old name for a while (Deprecating a setting or a template).

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x