Knowledge Base

How to Install MODs
Article ID: 31
Written By: Raimon
Written On: Sun Sep 02, 2007 5:40 pm
Description: Explains how to install MODs for phpBB, based on the text file usually accompanied with all MODs.
link to this article on phpbb.com: Select All
[kb=how-to-install-mods]How to Install MODs[/kb]
link to this article on your own board: Select All
[url=http://www.phpbb.com/kb/article/how-to-install-mods/]Knowledge Base - How to Install MODs[/url]

Before you begin, you must make a backup of all your files.

First you download the MOD that you want in the MOD section. Then you just open the install file (usually in a .txt file or .mod file).

Not hard to do: open the specific file into a text editor (notepad, wordpad, editplus, etc.)

1) The "COPY" action :
If in a MOD, you see something like this :

Code: Select all
#
#-----[ COPY ]------------------------------------------
#
copy file.php to file.php
copy file.tpl to templates/subSilver/file.tpl

This just means that you have to upload the file "file.php" into the phpBB root directory, and the file "file.tpl" into the template directory, without editing them.


2) The "OPEN" action :
This is the first basic action to do :

Code: Select all
#
#-----[ OPEN ]------------------------------------------
#
common.php

Not hard to do - open the specific file into a text editor (notepad, wordpad, editplus, etc.)


3) The "FIND" action :
After the "OPEN" action, this is other the most commonly used action because you have to find something before you may do anything.

Code: Select all
#
#-----[ FIND ]------------------------------------------
# around line 184
//
// Show 'Board is disabled' message if needed.
//

After you have opened a file in your text editor, search for what the MOD says, then do any actions on or around that line that comes after it.


4) The "BEFORE ADD" action :
In the install file, you may see :

Code: Select all
#
#-----[ BEFORE, ADD]--------------------------------------
#
include($phpbb_root_path . 'attach_mod/attachment_mod.'.$phpEx);

So, after you have found the code in a previous action, you add before what the MOD says to add. In my example, the result will then be :
Code: Select all
include($phpbb_root_path . 'attach_mod/attachment_mod.'.$phpEx);
//
// Show 'Board is disabled' message if needed.
//



5) The "AFTER ADD" action :

Code: Select all
#
#-----[ AFTER ADD]------------------------------------------
#
include($phpbb_root_path . 'attach_mod/attachment_mod.'.$phpEx);

It's the same as the "BEFORE" action, but instead of adding your code before the text, you have to add it after.

Example how it must look :
Code: Select all
//
// Show 'Board is disabled' message if needed.
//
include($phpbb_root_path . 'attach_mod/attachment_mod.'.$phpEx);



6) The "REPLACE WITH" action :
Code: Select all
#
#-----[ REPLACE WITH ]------------------------------------------
#
<form action="{S_POST_ACTION}" method="post" name="post" onsubmit="return checkForm(this)" {S_FORM_ENCTYPE}>

This action is always used with the "FIND" action. You have to find a section of code to replace it with.
But you have to be careful with this action if you have others MODs installed on your forum.

It is recommended that you do not use this action. Use in-line actions instead.

Example :

Code: Select all
#
#-----[ FIND ]---------------------------------------------
# around line 225
<form action="{S_POST_ACTION}" method="post" name="post" onsubmit="return checkForm(this)">

#
#-----[ REPLACE WITH ]---------------------------------------
#
<form action="{S_POST_ACTION}" method="post" name="post" onsubmit="return checkForm(this)" {S_FORM_ENCTYPE}>

In this example, I have to search for :

Code: Select all
<form action="{S_POST_ACTION}" method="post" name="post" onsubmit="return checkForm(this)">

...and replace it with this :

Code: Select all
<form action="{S_POST_ACTION}" method="post" name="post" onsubmit="return checkForm(this)" {S_FORM_ENCTYPE}>

...so, the end result will be :

Code: Select all
<form action="{S_POST_ACTION}" method="post" name="post" onsubmit="return checkForm(this)" {S_FORM_ENCTYPE}>



7) The "IN-LINE FIND" action :
This is about the "IN-LINE AFTER, ADD", "IN-LINE BEFORE, ADD", and the "IN-LINE REPLACE WITH" actions. These are explained later on, the best action to use by the MOD's authors.

This action is, again, always used with the "FIND" action.

Code: Select all
#
#-----[ IN LINE FIND ]------------------------------------------
#
t.topic_title,

It's a little hard to understand like this, I'll give you an example.

Code: Select all
#
#-----[ FIND ]------------------------------------------
#
$select_sql = ( !$submit ) ? ", t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig" : '';
#
#-----[ IN-LINE FIND ]------------------------------------------
#
t.topic_title,

You look for the section that is in the FIND action and then you find the code in the IN-LINE section within the piece of code you found earlier.


8) The "IN-LINE AFTER, ADD" action :
Looks like this :
Code: Select all
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
t.topic_desc,

In fact, it's better to use the "REPLACE" action (in the case that you have others MODs installed).
This action is used with the "FIND" action and the "IN-LINE FIND" action.

Example :

Code: Select all
#
#-----[ FIND ]------------------------------------------
#
$select_sql = ( !$submit ) ? ", t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig" : '';
#
#-----[ IN-LINE FIND ]------------------------------------------
#
t.topic_title,
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
t.topic_desc,

Here, you have to search for an entire line (original line) :

Code: Select all
$select_sql = ( !$submit ) ? ", t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig" : '';


In this line, you have to search for some code :
Code: Select all
t.topic_title,


...and to add directly after :
Code: Select all
t.topic_desc,


...so your line will become (modded line) :
Code: Select all
$select_sql = ( !$submit ) ? ", t.topic_title, t.topic_desc, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, pt.post_subject, pt.post_text, pt.bbcode_uid, u.username, u.user_id, u.user_sig" : '';



9) The "IN-LINE BEFORE, ADD" action :
It's the same as the "IN-LINE AFTER, ADD" action, but you have to add the code before what you find instead of after.

Code: Select all
#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
, $topic_desc


Example :
Code: Select all
#
#-----[ FIND ]------------------------------------------
#
prepare_post($mode, $post_data, $bbcode_on, $html_on, $smilies_on, $error_msg, $username, $bbcode_uid, $subject, $message, $poll_title, $poll_options, $poll_length);
#
#-----[ IN-LINE FIND ]------------------------------------------
#
$poll_length)
#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
$topic_desc,

You have to search for an entire line (original line) :

Code: Select all
prepare_post($mode, $post_data, $bbcode_on, $html_on, $smilies_on, $error_msg, $username, $bbcode_uid, $subject, $message, $poll_title, $poll_options, $poll_length);


...in this line, you have to find :
Code: Select all
$poll_length)


...and to add directly before :
Code: Select all
$topic_desc,


...so your line will become (modded line) :
Code: Select all
prepare_post($mode, $post_data, $bbcode_on, $html_on, $smilies_on, $error_msg, $username, $bbcode_uid, $subject, $message, $poll_title, $poll_options, $topic_desc, $poll_length);



10) The INCREMENT Action:

Code: Select all
#
#-----[ FIND ]------------------------------------------
#
Powered by <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB</a> &copy; 2001, {%:1} phpBB Group<br />{TRANSLATION_INFO}</span></div>
#
#-----[ INCREMENT ]-------------------------------------
#
%:1 +10

The INCREMENT action is used to add or subtract numbers. This is most useful for colspans or rowspans in templates.

The INCREMENT action needs to be preceded by a FIND or an IN-LINE FIND - you need to replace the number you want to add or subtract to with {%:1}. If you have multiple numbers within the line that you want to add or subtract to, use {%:2}, {%:3}, and so on.

In the INCREMENT action, you state which one of the numbers in the FIND you want to add or subtract to and then how much you actually want to add or subtract to. To add, use + and to subtract, use -. You can put nothing after you say which number you want to increase and it will be the same as +1. Here are some examples.

Code: Select all
#
#-----[ INCREMENT ]-------------------------------------
#
%:1

#
#-----[ INCREMENT ]-------------------------------------
#
%:2 -3

#
#-----[ INCREMENT ]-------------------------------------
#
%:3 +5

You can use IN-LINE INCREMENT as well which is the same as above.


11 ) The "SQL" action:
This is the action to do for altering the database (adding fields, adding tables, altering tables, etc).

Code: Select all
#
#-----[ SQL ]------------------------------------------
#
ALTER TABLE phpbb_topics ADD topic_desc varchar(255) DEFAULT '' AFTER topic_title

This means you need to execute the query that is in this action. The easiest way to execute this is using a program like phpMyAdmin. If you don't have access to phpMyAdmin, there are sites available which automatically parse the query into an PHP file, allowing you to simply upload the file and execute it, which in turn runs the query on the database. For example: http://sql.phpmix.com/index.php


12) The "SAVE/CLOSE ALL FILES" action :
This is the last action. Once you have done all your modifications, save and close your files and then upload them to your site. Check your forum to make sure you have applied the modifications correctly. If you encounter a mistake, double check the MOD file to make sure you have installed it correctly.

But don't forget : before all, backup your files and your database!


13) The DIY INSTRUCTIONS Action:
Code: Select all
#
#-----[ DIY INSTRUCTIONS ]------------------------------------------
#
CHMOD foo.php and bar.php to 777
Open in your web browser and follow the instructions in db_install.php

These are instructions that the person installing the MOD will have to do before the MOD can be installed fully. DIY means 'Do it yourself.' These instructions can include running a script that executes SQL queries, CHMOD files, or anything else.


14) MODx:
This is a new MOD instruction template called MODx based on XML.
You will notice an image within the 'MOD Database Release' topic if there is a MODx template present for that MOD:

Image

Normally you can open the file with your web browser. The filename will be something similar to "name_of_the_mod.xml".