The theme configuration file ‘themeconf.inc.php’ contains the properties and initial configuration of the theme and is hence the most important part of the theme development. It contains the following mandatory blocks:
- comment block containing theme properties, which is read by Piwigo to display information about the theme;
- block with essential theme configuration settings in $themeconf variable.
Both blocks need to follow the syntax provided by the theme development documentation. As the theme coding guidelines is not that extensive I downloaded several other themes and looked into their ‘themeconf.inc.php’. I copied what I understood and deemed useful to my ‘themeconf.inc.php’.
Additional the theme configuration file can contain code to:
- load translation file(s)
- set variables to be used in template files
- retrieval of theme settings from the database or Piwigo configuration file.
The code file will look like:
<?php 1. COMMENT BLOCK WITH THEME PROPERTIES 2. BLOCK WITH THEME CONFIGURATION VIA $themeconf 3. LOAD LANGUAGES 4. CHECK IF THEME UPGRADE AVAILABLE 5. SET VARIABLES FOR USE IN THEME TEMPLATES ?>
The next sections describe the setup for each of the above steps.
1. Setup comment block with theme properties
/* Theme Name: Elegant Metadata Version: 1.00 Description: Theme with focus on a clear layout and display of as many metadata as possible. Based on elegant theme v2.10.1 created by the Piwigo team. Theme URI: Author: Jan-Willem Kruse Author URI: https://www.fotokruse.eu/elegant-metadata-for-desktop-piwigo-theme/ */
The ‘Theme URI’ property is for the time being empty as the plugin has not been published yet in the extensions reprisotory on the Piwigo website. If published it will look like the one for the Elegant theme:
Theme URI: http://piwigo.org/ext/extension_view.php?eid=685
2. Setup the block with the theme configuration
The theme configuration block configures:
- name and folder of the theme;
- the relation with the parent theme;
- folder of icons and images used in the theme;
$themeconf = array( 'name' => 'elegant_metadata', 'parent' => 'default', 'local_head' => 'local_head.tpl', 'icon_dir' => 'themes/elegant_metadata/icon', // items below not strictly required, for completeness added based on Piwigo theme development documentation 'mime_icon_dir' => 'themes/default/icon/mimetypes', 'activable' => true, 'load_parent_local_head' => true, 'load_parent_css' => true, 'img_dir' => 'images', // Items not in theme coding guidelines, but in other themes 'theme_dir' => 'elegant_metadata', 'admin_icon_dir' => 'themes/default/icon/admin', );
3. Load the theme language file
The theme language file contains translations for the text displayed by the theme on the website.
// load theme language file load_language('theme.lang', PHPWG_THEMES_PATH.'elegant_metadata/');
4. Set the new theme as default
Now the initial setup and configuration has been completed we activate and make it the default one, so we can from now onwards see the effect of the further development of the theme.
Go to the admin area of Piwigo and activate the new theme under the Themes menu.
Not make the theme the default one.
Logout of Piwigo and login again. In both situations the theme should be displayed without errors.