Introduction

From SMFMods

Jump to: navigation, search

Contents

[edit] Introduction

In a nutshell, here's how SMF works:

  1. Your request starts off at index.php, in your forum's directory.
  2. index.php does some basic setup. It connects to the database, sets up the environment, and loads essential files (such as Load.php and Subs.php)
  3. index.php then works out where it needs to go, using the large array at the end of index.php
  4. Once it's worked out where it needs to go, it includes the necessary Source file

Control is now handed over to the Source file. It may do whatever it needs to do. Usually, this involves performing some type of database queries, and then loading a template.

[edit] SMF's Coding Structure

SMF's coding structure is similar to a MVC system. Essentially, this means that actions are split into two distinct files: Source files, and template files. Most actions have corresponding Source and Template files (for example, viewing a topic is handled by the Display.php and Display.template.php files).

[edit] Source files

Source files refers to the files in the "Sources" directory. These do all the work (database queries, etc) and store the data in the $context array.

[edit] Template files

Template files refers to the files in the "Themes" directory. These do not do any database queries. All they do is read the data in the $context array, and output it in a useable form (HTML).

If a custom theme is in use, SMF will first look in the custom theme's directory (Themes/theme name). If it is not found, SMF will load the template from the default theme (in Themes/default).

[edit] References

http://www.simplemachines.org/community/index.php?topic=133515.msg851203#msg851203

Personal tools