The mes_options.php file

The mes_options.php file offers the possibility to modify SPIP’s default configuration.

  • New in : SPIP 1.7

Options ?

When visiting a page (in Cache or not) SPIP execute certains actions, including loading the mes_options.php file.

In this file, it is possible to :

  • define PHP constants
  • adapt global values for personalisation
  • define functions (cf note on the performance)

See alos the complete listing of variables and constants in the glossary

Create mes_options.php file

By default SPIP does not provide this file. It must be created in the config/ directory [1]

mes_options.php is a PHP executable file, so it must start with <?php (be extremely vigilant here: there must not be any characters, spaces or blank lines before the opening tag <?php nor any after the closing tag ?>). SPIP adopts recent PHP conventions, so it is recommended that you no longer specify a ?> closing tag.

-  An example of the mes_options.php file:

<?php
// security
if (!defined('_ECRIRE_INC_VERSION')) {
	return;
}

// define constant
// forbid upload documents that are bigger than 500 KB
define('_DOC_MAX_SIZE', 500);

// Variable
// force the display of the drop-down menu starting in 2010 for
// the "Date of previous publication" field
$GLOBALS['debut_date_publication'] = '2010';

Advanced users

It’s possible in his personal file to refer to the spip_inititialisation() function in order to define the data directories and also, for example, to deal with several websites, using only one distribution (the standard calling of this function in inc_version.php will be automatically made ineffective)
About this topic, see also Mécanismes de fabrication des pages publiques et privées

Note on the performance

When created, this file is loaded everytime a page is viewed (both public and private pages). Consequently, this file must be ba as light and economic as possible)

See also

To debug PHP errors

On programmer.spip.net

Footnotes

[1in versions of SPIP prior to 1.9.2, this file was located in the ecrire/} directory

Author Mark, peetdu Published : Updated : 08/07/23

Translations : català, English, français, Nederlands