PHP Bulletin Board Home
News About Home
Features of phpBB Test drive phpBB Downloads Support for phpBB The phpBB Community Styles for customising phpBB 3rd party modifications to phpBB

Support Home | Knowledge Base Home | Submit Article | Search Articles | Browse Articles
 MOD Template Actions 
Description: These are the actions that are allowed in the MOD Template
Author: wGEric
Date: Tue Jan 14, 2003 5:09 pm
Type: Info
Keywords: mod, template, actions
Category: MODifications
MOD Template Actions

The actions are what the user's follow in order to install the MOD on his or her board. These are the most important part of the MOD Template and need to be done carefully and precise. Here is what actions look like (the word ACTION is replaced with the actual action).

Code:
#
#-----[ ACTION ]------------------------------------------
#


There needs to be one # above and below the line with the name of the action in it. If you want to add a comment to the action, you would do this.

Code:
#
#-----[ ACTION ]------------------------------------------
#
# The comment goes here
#


Comments can be as many lines long as you want. Just make sure you add the appropriate number of # to make it so that you have one blank one at the bottom.

Here is a list of the possible actions you can use. After this list will be a detailed explanation of each action.

Code:
SQL
COPY
DIY INSTRUCTIONS
OPEN
FIND
REPLACE WITH
AFTER, ADD
BEFORE, ADD
INCREMENT
IN-LINE FIND
IN-LINE AFTER, ADD
IN-LINE BEFORE, ADD
IN-LINE REPLACE WITH


The SQL Action

Code:
#
#-----[ SQL ]------------------------------------------
#
INSERT INTO phpbb_config ( config_name, config_value ) VALUES ('foo', 'bar');


The SQL action tells the person who is installing the MOD that they need to execute the SQL queries. The SQL queries need to use the default table prefix (phpbb_), be written for MySQL, and end in a semicolon ( ; ). You can put multiple queries under the same SQL action. Like this

Code:
#
#-----[ SQL ]------------------------------------------
#
INSERT INTO phpbb_config ( config_name, config_value ) VALUES ('foo', 'bar');
INSERT INTO phpbb_config ( config_name, config_value ) VALUES ('foo2', 'bar2');


If you have a script that the user can use to perform the SQL queries for them, you need to use the DIY INSTRUCTIONS action to tell the user to execute that script. You can't put under the action that the user needs to use the update script or have a comment with nothing under the action. Do not use this action if you want users to use the update script instead of executing the SQL manually.

The COPY Action

Code:
#
#-----[ COPY ]------------------------------------------
#
copy foo.php to foo.php
copy includes/bar.php to includes/bar.php
copy images/*.gif to images/*.gif
copy files/*.txt to files/*.txt
copy cache/*.* to cache/*.*


The COPY action is used to copy files from the MODs package to the board the MOD is being installed on. Each file to be copied needs to have its own line that starts with copy and has to in the middle. The part after copy and before to is the file in the MODs package. It needs to be the path from the root of the MODs package. The part after the to is where the file will go and be named from the root of the phpBB install. You must put a filename for both parts in each copy line.

You can use wildcards (*) to copy multiple files without having to list all of them. See the example above to see how to use wildcards.

The DIY INSTRUCTIONS Action

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


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

The OPEN Action

Code:
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/index_body.tpl


The OPEN action is used to open a file for editing. An OPEN action needs to be done before any FIND or other actions that edit a file. The file name needs to have the path from the root of phpBB and is case sensitive. All slashes need to be forward (/ not \) and no slash is needed at the beginning of the file name.

The FIND Action

Code:
#
#-----[ FIND ]------------------------------------------
#
$lang['General'] = 'General Admin';


The FIND action is used to find certain code within a file so that it can be edited or have more code added around it. FINDs need to be unique so that the edits are done at the right spot. FINDs can be partial and don't have to be at the beginning of the line.

You can perform multiple actions on one FIND. So, you can do a FIND and then on that FIND do a BEFORE, ADD, AFTER, ADD, IN-LINE actions, and a REPLACE WITH.

Using the code that is in the above example, all of the following would be acceptable.

Code:
#
#-----[ FIND ]------------------------------------------
#
'General Admin'


Code:
#
#-----[ FIND ]------------------------------------------
#
$lang['General'] =


Code:
#
#-----[ FIND ]------------------------------------------
#
Admin';


As you can see, the code that is under the FIND isn't the whole line and comes from different parts of the line. Although the FIND is partial, the whole line will be what the rest of the actions will work with. If you want to work code within a line, the IN-LINE actions are what you will need to use.

The REPLACE WITH Action

Code:
#
#-----[ REPLACE WITH ]------------------------------------------
#
$lang['General'] = 'New string';


The REPLACE WITH action is used to replace code with different code. This action needs to be preceded with a FIND action and everything within the FIND action will be replace with this action.

We don't have a delete action so to delete code, you would use the REPLACE WITH action to either comment out the code, or replace it with a comment saying the code was deleted.

We recommend that you avoid using the REPLACE WITH action. If you can, use IN-LINE actions or any others that would work instead.

The AFTER, ADD Action

Code:
#
#-----[ AFTER, ADD ]------------------------------------------
#
if ( $userdata['user_level'] == ADMIN )
{
edit_user();
}


The AFTER, ADD action is used to add code to the file. It must be preceded by a FIND action because it adds the code after the line(s) that have been found in the FIND action.

If you want to add code after a certain part within one line, you need to use IN-LINE actions. This action will only add code after the line(s) that was found in the FIND.

The BEFORE, ADD Action

Code:
#
#-----[ BEFORE, ADD ]------------------------------------------
#
if ( $userdata['user_level'] == USER )
{
redirect('index.'.$phpEx);
}


The BEFORE, ADD action is exactly like the AFTER, ADD action except it adds the code before the line(s) that were found in the FIND action.

If you want to add code before a certain part within one line, you need to use IN-LINE actions. This action will only add code before the line(s) that was found in the FIND.

The INCREMENT Action

Code:
#
#-----[ 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 to numbers. This is most useful for colspans or rowspans in the template.

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 say which one of the numbers in what is in the FIND you want to add or subtract to and then how much you 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:
#
#-----[ INCREMENT ]-------------------------------------
#
%:1

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

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


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

The IN-LINE FIND Action

Code:
#
#-----[ FIND ]------------------------------------------
#
$lang['Admin'] = 'General Admin';

#
#-----[ IN-LINE FIND ]------------------------------------------
#
General


IN-LINE FIND is used to find a specific part to one line so that you can do edits within the line. IN-LINE FIND must be preceded by a FIND. All IN-LINE actions need to have an IN-LINE FIND preceding them.

The IN-LINE AFTER, ADD Action

Code:
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
 phpBB


The IN-LINE AFTER, ADD action adds code within the same line but after what was found in the IN-LINE FIND. If using the example in the IN-LINE ACTION and the example for this action, the following would be the result.

Code:
$lang['Admin'] = 'General phpBB Admin';


IN-LINE AFTER, ADD must be preceded by an IN-LINE FIND and can only be one line. You cannot add multiple lines using IN-LINE AFTER, ADD.

The IN-LINE BEFORE, ADD Action

Code:
#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
phpBB


The IN-LINE BEFORE, ADD action is just like the IN-LINE AFTER, ADD action except it adds code before what was found in IN-LINE FIND. Again using the same examples and using IN-LINE BEFORE, ADD, the following would be the result.

Code:
$lang['Adminl'] = 'phpBB General Admin';


Just like IN-LINE AFTER, ADD, you must precede IN-LINE BEFORE, ADD with an IN-LINE FIND and it cannot be used to add multiple lines.

The IN-LINE REPLACE WITH Action

Code:
#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
Common


IN-LINE REPLACE WITH is used to replace all of the code that was found in IN-LINE FIND with what is in the IN-LINE REPLACE WITH. Using the example from IN-LINE FIND and for this action, the following would be the result.

Code:
$lang['Admin'] = 'Common Admin';


Like the other IN-LINE actions, IN-LINE REPLACE WITH must be preceded by an IN-LINE FIND and can only be one line. You cannot do a replace that is more than one line.


That is it for the list of available actions that you can use. You cannot make up any new actions to use in your MOD. You should be able to do what you want with the above actions. If you can't and have a suggestion for a new action, please send a private message to one of the Modifications Team Members.

Username: Password:
News | Features | Demo | Downloads | Support | Community | Styles | Mods | Links | Merchandise | About | Home
 © Copyright 2002 The phpBB Group.