Mod authors: Changes in SMF 2.0

SMF 2.0 has had some large code changes, a lot of which affect how mods are written. Code has been restructured for greater efficiency, several new features have been added (which make certain mods obsolete), etc. Due to the volume of changes, almost all mods designed for SMF 1.1 will not work with SMF 2.0. This document is a short introduction on converting SMF 1.1 mods to SMF 2.0. It is not an exhaustive reference, but should help you get your mod up and running on SMF 2.0.

 Overview: " class="bbc_link">Database Queries " class="bbc_link">Column Names" class="bbc_link">db_query function" class="bbc_link">Example" class="bbc_link">$ID_MEMBER removal" class="bbc_link">Menus " class="bbc_link">Main Menu</li>" class="bbc_link">Administration Menu</li></ul></li></ul> <span id="post_db"> <span style="font-size: 4;" class="bbc_size">Database Queries SMF 1.1 only supported MySQL, and hence, MySQL functions are usually used in mods. In SMF 2.0, a database abstraction layer has been added, allowing for different database systems to be used (at the time of writing, MySQL, PostgreSQL, and SQLite are supported). As such, all MySQL function calls willl need to be changed to use the new SMF functions.

Because multiple database systems are supported, it is recommended that you do not use MySQL-specific SQL features (eg. ON DUPLICATE KEY UPDATE. If you stick to SQL92 SQL features, you can be assured that your mod should work on the majority of modern <acronym title="Relational Database Management Systems">RDBMS systems.

The main functions are listed below: You will find a more indepth and detailed information about the SMF 2.0 functions in our SMF 2.0 Database Functions topic on the community forums. " class="bbc_link">Back to overview

<span id="post_db_column"> Column Names In SMF 2.0, all uppercase column names have been changed. This was done because some database systems do not support uppercase column names. The index columns that had uppercase names in SMF 1.1 (eg. ID_MSG, ID_TOPIC, ID_MEMBER) have had their names changes to lowercase (id_msg, id_topic, id_member). Additionally, any columns that used camel case (memberName) have changed to use an underscore between words (member_name)

An example is below " class="bbc_link">Back to overview

<span id="post_db_example"> Code example This code is for SMF 1.1: : <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a> And this is the SMF 2.0 equivalent: : <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a> " class="bbc_link">Back to overview

<span id="post_id"> $ID_MEMBER In SMF 1.1, the $ID_MEMBER variable contained the current user&#039;s ID. SMF 2.0 has removed this variable. Any code using $ID_MEMBER will need to be edited so it uses either $user_info&#91;&#039;id&#039;] or $context&#91;&#039;user&#039;]&#91;&#039;id&#039;].

<span id="post_menu"> <span style="font-size: 4;" class="bbc_size">Menus  <span id="post_menu_main"> Main menu In SMF 1.1, each theme had its own main menu in index.template.php. For example, the code for the Calendar button in the SMF 1.1 default theme (Core) looks like this: : <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a> SMF 2.0 has moved all the menu items to Subs.php, in a &quot;setupMenuContext&quot; function. This simplifies theme writing, and makes it easier for mod authors (just edit the Subs.php file, and a button appears on all themes). As an example, the Calendar button has become: : <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a> In Subs.php. A new feature is that each button can have several &quot;sub-buttons&quot;. In the future, some themes may render these sub-buttons as a dropdown menu. This is done on the simplemachines.org community forum. " class="bbc_link">Back to overview

<span id="post_menu_admin"> Administration menu In SMF 1.1, the administration menu was defined in the adminIndex function in Subs.php. For example, the &quot;Forum&quot; section looks like: : <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a> Much like the main menu, SMF 2.0 has seperated the menu items from the actual menu itself (which is handled by Subs-Menu.php and the theme). The code for this same menu looks a lot simpler in SMF 2.0: : <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a>