26.3. How to install new modules

Figure 26-4. Administration panel: Modules.

Administration panel: Modules.

ImportantCheck versions!
 

Before we start, check that the version of the module you are about to install is compatible with the PHP-Nuke version of your installation!

The add-on modules of PHP-Nuke are of various types (see Section 8.3 for some examples), but can be grouped together in 3 different categories:

  1. Modules that do not change the database structure (see Section 26.3.1).

  2. Modules that change the database structure (see Section 26.3.2).

  3. Modules that change both the database structure and the orininal PHP-Nuke files (see Section 26.3.3).

26.3.1. How to install modules that do not change the database structure

These are the simplest modules to install. Their installation consists only of copying the module's files in the aproppriate folders in PHP-Nuke. There are no changes to the original tables and no new tables involved.

These modules may consist of only a public part, only an administration part , or both. But how tell if a certain module requires a database modification or not? Generally, a module package comes with the following folders:

html (1)
html/modules (2)
html/admin (3)
html/images (4)
html/sql (5)
(1)
This is a container folder that is not involved in the installation.
(2)
The subfolders of this folder constitute the public part of the module and should be copied under a directory with the module's name in the PHP-Nuke modules folder.
(3)
The subfolders of this folder constitute the administration part of the module and should be copied under PHP-Nuke's admin folder.
(4)
Contains any images used by the module. Its contents should be copied in the PHP-Nuke images folder.
(5)
Contains the file with all the necessary modification commands for the database, if any. It is the existence of such a file (sometimes not with the .sql ending) that suggests that the module in question requires changes in the database. However, its absence is not a sure sign that such a change is not needed at all: some modules will make their changes to the database on-the-fly, e.g. through some install.php PHP script that we will have to open with our browser during installation.

26.3.2. How to install modules that change the database structure

These modules, although they will not change any original PHP-Nuke files, they will require a change in the PHP-Nuke database. The required change in the database may be of two types:

  1. Some tables are appended to the database, but without changing any of the existing ones.

  2. The original PHP-Nuke tables must be changed.

The installation of these modules consists in the copying of their files into the appropriate folders (see Section 26.3.1 for the details, remember that they don't overwrite or change any original PHP-Nuke file) and the import of a .sql file (using phpMyAdmin, as shown in Section 3.4.2, or the command line as in Section 3.2.4), or the opening of some install.php file through the browser that will make the database changes automatically.

26.3.3. How to install modules that change the database structure and the files

There are module that, in order to function properly, require the addition of functions in the original files of PHP-Nuke. These modules will overwrite mainfile.php, modules.php, or some other file.

CautionBeware of subsequent installations!
 

If you install a module that changes PHP-Nuke's original files, you may not be able to conduct the installation of another one that requires changes in those files too! The new module's installation script may not find the expected code to modify, since it will have been changed by the previous one.

For example, in PHP-Nuke 6.0 there were two interesting add-on modules, Indy News and Groups, that both required changes to be made in mainfile.php. In order to get them both to work, we had to do the changes in mainfile.php by hand, resulting in a file that contained a mix of modifications by both modules.

WarningAutomatic upgrades may not work any more!
 

In case you had to change the original tables of PHP-Nuke (i.e. you had not just to append some new tables to the database, but to change existing ones), then you may find out the next time you want to upgrade, the automatic upgrade scripts that come with each new PHP-Nuke version (see Chapter 4) do not work any more!

This is because the scripts will search for the original table structure to upgrade, but will find some new one instead. In this case it is recommended to have a look at the upgrade scripts and do the changes manually, using either a graphical frontend, like phpMyAdmin (Section 3.3) or the MySQL command line (Section 3.2.4).

The same warning applies to file changes during upgrades: it is best to make the changes in the files by hand, also for those files of the new modules. Such a procedure can be very painful and time-consuming. It is recommended that you use a local test server for all these changes and that you do not upload the modified files, until you have tested them thoroughly and made all backups of the production system. (See Figure 26-2 and Section 7.1, for PHP-Nuke's own backup function, Section 3.3 for phpMyAdmin's functionality, which also includes a very good web interface to database backups and Section 27.16, for home-made scripts that automate the backup work for you).