top

User functions

Sometimes there is a need to customize CMSimple_XH. It would be quite possible to make needed changes directly in the original files – but that would not be wise. At the latest, with the next update, these changes would be overwritten. It is better to pack larger changes or new functionalities into a separate plugin.
Smaller changes, for example only one or two new or changed functions, can simply be placed in the file cmsimple/userfuncs.php.

userfuncs.php

The file cmsimple/userfuncs.php is, as the name says, a user file that contains user functions. So it is always an individual file. It is not delivered with CMSimple_XH – so you have to create it by yourself if needed. Updates will not overwrite this file.

CMSimple_XH will always include and process this file, if available, before the plugins. Therefore, it is the appropriate place to add needed functionality(s) to CMSimple_XH or to change existing ones.

 

The file is a normal PHP file (encoded utf-8 without BOM) and always starts like this:

<?php
...

Here you can now note your individual adjustments. The file can be changed or extended at any time. (Example for a concrete application: Custom 404 page)

Modify XH Core functions

If a system core function of CMSimple_XH is to be changed, one can copy this function to cmsimple/userfuncs.php, delete or comment it out at the original place and make the own changes to the copy. After an update, it is often sufficient to remove the function from the original place again.

If code in the global visibility area (i.e., outside a function) has to be changed, you usually can’t move this code to cmsimple/userfuncs.php, because the order of execution has to be respected. In this case, it is best to keep the changes to the system core files to a minimum, and as far as possible write a new function in cmsimple/userfuncs.php and call it at the place where the changes are wanted.

Tip

In order to be able to keep track of changes or additions later, you should always document them well, or at least include meaningful comments in the code. Example:

// Modification: ...

Or also more detailed:

// Modification start:
// replaced in cmsimple/tplfuncs.php:
// function XH_anything()
...
// Modification end

Generally useful changes

If you think your change might be useful to others, post it in the Open Development Forum (or one of the non-English forums). If others share your opinion about the general usefulness, chances are good that the change will be included in the next version of CMSimple_XH, so you won't have to make the changes again in the next update.

userprelude.php

Since CMSimple_XH 1.6.5 the file cmsimple/userprelude.php is included before the cms.php if it exists. This offers the possibility to do some early customizations without having to change the index.php (which is especially useful for multilingual websites with multiple index.php). In particular, this file can be used for a maintenance mode by stopping the script execution before including cms.php.

BOM

BOM is the abbreviation for byte order mark. That's an important concept for platform interoperability regarding many multibyte encodings, e.g. UTF-16 and UTF-32. It is necessary, as different OSs expect those encodings in different byte orders (big-endian vs. little-endian).

But for UTF-8 the byte order is fixed for all platforms, so the BOM has lost it's original meaning. However, it is used by many editors to mark a file as being UTF-8 encoded. That's probably not the best idea, and the Unicode Standard does not recommend using a BOM in UTF-8 encoded files. Often the BOM doesn't matter though, but for PHP files and files that will be include()d by PHP the BOM causes a problem: the BOM will be sent to the browser as soon as the file is processed. As the HTTP response is already started, later sending of HTTP headers will be suppressed, which might cause different malfunctions of the script.

PHP

PHP = Hypertext Preprocessor, originally Personal Home Page Tools

PHP is a scripting language commonly used to create dynamic websites.

utf-8

utf-8 = 8-bit UCS Transformation Format

The most commonly used type of character encoding on the World Wide Web.

More about this at Wikipedia.

CMSimple_XH requires utf-8 without BOM.