Creating a Copy Style

For the purposes of illustration, this chapter will discuss the usage of a sample style called subBook. Instead of downloading and uncompressing this style, it was created as a quickly renamed copy of the subSilver style.
 
If you would like to create your own subBook style so you can follow along, follow these simple instructions.

Time For Action—Creating a Copy Style
  1. Make a copy of the templates/subSilver directory. The copy should contain all the same files found under subSilver.
  2. Change the name of the copy directory to subBook.
  3. Rename the subSilver.cfg and subSilver.css files to subBook.cfg and subBook.css, respectively.
  4. Open the theme_info.cfg file for editing. In this file, you will see subSilver used several times. Change each of these instances to subBook. Take care that you do not delete or change anything else in the file. Remember to follow the proper editing procedures you learned earlier.
  5. The name of the subSilver style is referenced in around forty to fifty lines inside template files in your subBook directory. The exact files and number of times vary depending on the version of phpBB 2.0 you are using. When creating a new style from subSilver as we are doing, you need to change all these references to the name of the new style (subBook in our case). Clearly, this step will take some time. This will not affect our installation or uninstallation examples, so you may skip most of this for now. Some advanced text editors have special search and replace features that can help you do this more quickly. At the very least, do these steps on the overall_header.tpl file.
  6. Save and close all open files.

What Just Happened?

Every style available for phpBB is based around a set of files stored in the templates directory. The easiest way to create a new style is to copy the files of another and make a few changes to some of the copied files. These files are the configuration files, such as subSilver.cfg and theme_info.cfg, which phpBB uses for installing and managing styles. The Cascading Style Sheet file, subSilver.css in this case, was also renamed. As a result, references to subSilver.css in overall_header.tpl also had to be changed to the new name of that file. Completing these steps gives you a new style, which you can edit as much as you like without affecting your forums' other styles.

Installing One Element at a Time

Once you have a new style to install, either from downloading or copying subSilver, you need to place that style's directories and files into the templates directory of your forum. phpBB's Administration Control Panel can automatically detect all styles placed into this directory. If your forum is on a remote server, as most forums and websites tend to be, then you will have to upload the directories and files to that server via one of the methods supported by your web hosting company. This is usually through File Transfer Protocol (FTP), SSH, or some other setup. Once you have copied or placed the files into templates, you have completed two thirds of the style installation already:

With the new style's files placed in your forum file system, you are now ready to install the style through phpBB's Administration Control Panel. Log in to your forum using an administrator account and enter the Control Panel. In the navigation menu frame, scroll down to the Styles Admin section. There are several options here; we are only interested in the Add link for the moment. Click this link to enter the Styles Administration page.

The Styles Administration page lists all the uninstalled styles phpBB has detected in your templates directory. You may notice that this page uses both theme and style to refer to the styles. This confusion stems from the fact that we have already installed the image set and template style elements simply by placing them into the templates directory. All that remains is to install the theme element, and thereby complete the style's installation. To install a theme, just click the Install link next to the entry in the list. phpBB will now show the style in the drop-down selection list found in user profiles and the phpBB configuration page:

Troubleshooting

phpBB is a complicated set of scripts, so even something that should be simple, like installing a style, can cause you problems. There are many causes of these problems, ranging from designer mistakes to errors in the copying of the files, but all of them are easy to fix. Let us examine some of the more common troubles encountered by forum administrators in the past.

Style Does Not Appear in Administration

If a style does not appear in the Styles Administration page after you have copied it to the templates directory, there is usually a problem with the theme_info.cfg file that should be in the style's directory. Make sure this file has been copied and that the name of the file has not been changed. If the file is present and named correctly, then there is a problem inside the file itself. Some styles have been distributed with errors in this file.

Open theme_info.cfg for editing. It should resemble the subSilver file shown in the figure that follows. Note that each line begins with $subSilver[0], followed by other characters. The subSilver part is extremely important, and must be spelled in exactly the same manner as the name of the style's templates directory and cannot contain any spaces. The name will be different for each template, of course. phpBB will consider all of these to be completely different things:

  • subSilver
  • subSilver
  • Subsilver
  • SubSilver
  • subsilver

This screenshot shows a portion of an unaltered subSilver theme_info.cfg. Only our first option, subSilver, would be correct in this instance. Check each line of theme_info.cfg and make any corrections needed to the file or, if necessary, rename the style's templates directory. In certain cases, the latter will be an easier method of correcting the problem. Other styles will have different names for their directory and in theme_info.cfg, but the name must be the same in both places.





© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.