The Trouble with Templates

One very important aspect of modification installation remains, just when you thought you had finished it. When you install have installed at least one other template on your forum. With so many templates existing, it is not practical for authors to mention all of them in their instructions. Since every phpBB forum has subSilver installed at some

point, and many templates are built from subSilver, only that one template gets mentioned, with an unspoken understanding that it is really a reference to all templates.

The trouble with templates is that you have to install every modification's template file changes to all your installed templates, even though the instructions do not tell you to do this. Also, if you install modifications and later install new templates, you have to apply the modifications to those templates. Should you forget to modify a template, any forum members using that template will not be able to access the modification's features unless they switch to another that you did edit.

Uninstalling Modifications

Occasionally, you may have a need to remove a modification after installing it. Maybe you've found that two modifications are conflicting with each other or a modification does not live up to your expectations. Whatever the reason, uninstalling tends to be easier than installing.

There are two methods of removing a modification's changes to your files. Since you created backups before editing any of your files, you can replace your current files with those backup copies. This reverts the forum's files to the same condition they were in before the modification was installed. If you have made changes to the files other than installing this modification, then you should not restore the backup files. Doing so in such a case will cause your other changes to be lost.

The second method is to go through the modification's instructions as if installing, but invert the action commands. For example, if the instructions have a Find action followed by an After, Add action, you would locate and delete the After, Add code. In the case of a Find and Replace With combination, you would search for the Replace With code, remove it, and place the Find code at that location. To further illustrate these concepts, the following example removes the Search button added to posts in the earlier modification installation exercise.

Time For Action—Uninstalling a Small Modification

12. Locate and open the templates/subSilver/viewtopic_body.tpl file of your forum in a text-editing program.

13. Use the text-editing program's search feature to locate this line of text in the file. Again, most programs allow accessing such a feature from their menus or by pressing Ctrl+F on Windows systems.

//--></script><noscript>{postrow.ICQ_IMG}</noscript> {postrow.SEARCH_IMG}</td>

  1. Now, locate the text {postrow.SEARCH_IMG} within that line.
  2. Delete this text and the single space before it. The line should once again look as it originally did:

//--></script><noscript>{postrow.ICQ_IMG}</noscript></td>

What Just Happened?

By reversing the actions you took to install the Search button modification, you have removed it from your forum. Instead of finding the original code and adding to it, you searched for the modified code. Then you removed the extra code added by the original modification. This restored the altered file to its original state.

Removing Other Changes

The need to remove new files and database changes is common to both methods of removing file changes reviewed before the previous example. New files added by a modification are quick and easy to deal with: just delete them. Removing database changes is a more complex aspect of uninstallation; however, phpMyAdmin is a handy tool for making this simple. When a modification has added a new table or a new column in a table, you can locate this addition in phpMyAdmin and click a Delete link, which often takes the form of a trash can icon, next to it. phpMyAdmin will ask you to confirm the deletion (or dropping, as it is called when dealing with tables or columns); do so and the change will be gone.

Example Modifications

Thousands of modifications for phpBB have been released for public use in the years since phpBB first appeared. Think of almost any feature you might like to add to or remove from a phpBB forum, and there will probably be at least one modification for that already. New modifications are created and released each week so the possibilities for customizing a forum through this method are endless.

One of the most popular modifications is the massive File Attachment Mod, which contains over 140 files. It adds a new feature to phpBB's posting forums allowing users to upload files that will be attached to and displayed with their posts. Another commonly used example is Modify Profile, formerly known as Add New Field to Profile. This modification is an instruction guide for adding new information fields to user registration and profile-editing forms. Many different kinds of fields can be added, ranging from simple text entry boxes to drop-down selection lists. The data stored in the new field can also be displayed in public profiles, topics, posts, and other places throughout a forum.

Dozens of modifications alter or add new BBCodes. User and administration management tools, online games, stores, chat rooms, recent topics, download systems, phpBB bug fixes or upgrades, and website portals are examples of some other widely used modifications.

These lists are only scratching the surface when it comes to describing the types of modifications available for your use. It will definitely be worth your time to check out a few websites that list modifications; you will find something that you want to install at your forum if you look closely enough. Chances are you will find many things to use in customizing your forum.

Moving Elements

Some layout alterations can be made to your forum without taking the time to search for a detailed modification. While you can find modification downloads for some of these, modifications often don't deal with layout issues very well. The differences in templates, and sometimes those created by other modifications, often force forum administrators to rearrange their layout without any help. In order to move elements like this, you will need to have at least a basic knowledge of HTML coding.

You might have noticed that subSilver and subBook have some statistical data and a login box at the bottom of their forum index pages. One popular change that you can make is to move one or more of those elements to another part of the page. By finding the layout code that creates them in index_body.tpl and placing it closer to the top of the file, you can emphasize that your users should log in or the number of users and posts on your forum.

Adding New Elements to Your Forum

Creating new areas in your forum will usually require a full modification, complete with instructions. There are a couple of simple things that can be done without a modification, however. One of these is to add a new link to your forum's header menu.

Time For Action—Adding a Menu Link

16. Locate and open the templates/subBook/overall_header.tpl file for editing. You can use the subSilver overall_header.tpl file instead, if you like.

17. Find the line in this file containing the code <!--BEGIN switch_user_logged_out -->. There will be several tab spaces at the beginning of the line.

18.Insert the following code on a new line before the code you just located: &nbsp;<a href="{U_VIEWONLINE}" class="mainmenu"><img src="templates/subBook/images/icon_mini_members.gif" width="12" height="13"border="0" alt="{L_WHO_IS_ONLINE}" hspace="3" />{L_WHO_IS_ONLINE}</a></span>&nbsp;

19. Save your changes to the file and view your forum. You may need to reload or refresh the forum page, but you should see a new Who is Online link with the other links near the top of the forum.

What Just Happened? The menu links of your forum, like Profile, FAQ, and Search, are created by HTML stored in the overall_header.tpl template file. By duplicating a line or series of lines that creates one of these links and altering the line a little, you can create a new menu link. In this case, the new link points to the viewonline.php file, which displays a list of users currently visiting the forum. If these steps were written up as a modification, they might look like this:

# #-----[ OPEN ]------------------------------------------ # templates/subBook/overall_header.tpl # #-----[ FIND ]------------------------------------------ # <!-- BEGIN switch_user_logged_out --> &nbsp;<a href="{U_REGISTER}" class="mainmenu"><img src="templates/subBook/images/icon_mini_register.gif" width="12" height="13" border="0" alt="{L_REGISTER}" hspace="3" />{L_REGISTER}</a></span>&nbsp; <!-- END switch_user_logged_out --> # #-----[ BEFORE, ADD ]------------------------------------------ # &nbsp;<a href="{U_VIEWONLINE}" class="mainmenu"><img src="templates/subBook/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_WHO_IS_ONLINE}" hspace="3" />{L_WHO_IS_ONLINE}</a> </span>&nbsp; # #-----[ SAVE/CLOSE ALL FILES ]--------------------------------------

#
# End

Adding New Languages

Another common change made by forum administrators is the installation of new language files. If you plan to have many visitors who are fluent in languages other than English or cannot read English, you might want to download and install a language pack from phpBB.com's Downloads section. Each language pack adds a new option to the Board Language drop-down list in user profiles and the Administration Control Panel. Selecting that option will cause the forum to be displayed in that language. Posts will not be translated, but many links and other default text will.

When adding language packs, you should keep in mind that you may have to edit the new language files. Some modifications will include new language files or instructions for editing language files. If you add a new language and do not copy these changes to that language, then some text will not appear on your forum. This situation is similar to that for modifications and templates; you must edit every language, even if the modification's instructions only mention one.

Summary

phpBB is excellent and powerful forum software in many areas. Customization possibilities are one of the strongest. With the skills and knowledge you've gained in this chapter, you can give your forum a complete face-lift or expand its features beyond anything you might have imagined. Specifically, you learned:

  • A phpBB style creates the appearance of a forum
  • Editing a style's components allows you to change any aspect of
    the appearance
  • Modifications are instructions for changing phpBB's features, and usually have a special format
  • How to install and remove styles and modifications downloaded from websites
  • Methods of editing any of phpBB's files and solving errors

Later chapters will expand on these topics somewhat by discussing details of creating your own styles and modifications.






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