No edit summary |
|||
(9 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{Needs work}} | {{Needs work|incomplete}} | ||
{{TOCright}} | |||
==What are global variables?== | ==What are global variables?== | ||
Global variables reside in global memory. They need to be pulled into scope before use in a function. The below code brings $context into scope for use inside a function. | Global variables reside in global memory. They need to be pulled into scope before use in a function. The below code brings $context into scope for use inside a function. | ||
Line 11: | Line 11: | ||
===General=== | ===General=== | ||
* $boarddir - a string containing the absolute path to the SMF installation. | |||
* $cachedir - a string containing the absolute path to the directory where all the cached files reside. | |||
* $cookiename - string | |||
* [[$context]] - an array of items for the template. This is used throughout SMF. | |||
* $options - an array of all the theme options defined by the user | |||
* [[$modSettings]] - an array holding all the management settings defined in the database table smf_settings | |||
* $scripturl - a string which holds the URL to the script. Used to build links to be displayed in the templates. Please refrain from using relative URLs. | |||
* $settings - an array of all the global theme settings | |||
* [[$smcFunc]] - array of functions for general use. | |||
* $sourcedir - a string containing the absolute path to the Sources directory. Useful for including source files. | |||
* [[$user_info]] - an array containing all the information about the current logged user. | |||
===Boards, topics, and posts=== | ===Boards, topics, and posts=== | ||
<ul> | <ul> | ||
<li>$attachments - an array holding all the info for attachments and is seen primarily in Display.php and largely processed in | <li>$attachments - an array holding all the info for attachments and is seen primarily in Display.php and largely processed in displayAttachmentContext().</li> | ||
<li>$board - an integer containing the current board's ID and is seen in most of the files for displaying posts and boards.</li> | <li>$board - an integer containing the current board's ID and is seen in most of the files for displaying posts and boards.</li> | ||
<li>$board_info - an array which contains all the information required to display a board.</li> | <li>$board_info - an array which contains all the information required to display a board.</li> | ||
<li>$topic | <li>$topic - an integer containing the current topic's ID and is seen in most of the files for displaying posts and boards.</li> | ||
<li>$topic_info - an array which contains all the information required to display a topic and all the posts therein.</li> | <li>$topic_info - an array which contains all the information required to display a topic and all the posts therein.</li> | ||
</ul> | </ul> |
Latest revision as of 06:41, 1 September 2015
This article needs some work for the following reason: incomplete This template may be removed when cleanup is complete. |
What are global variables?
Global variables reside in global memory. They need to be pulled into scope before use in a function. The below code brings $context into scope for use inside a function.
global $context;
The global variables are already accessible outside a function so there's no need to bring them into scope. In fact, the call can be done anyway with no harm at all.
List of global variables
SMF contains several globals. Each has its own unique purpose.
General
- $boarddir - a string containing the absolute path to the SMF installation.
- $cachedir - a string containing the absolute path to the directory where all the cached files reside.
- $cookiename - string
- $context - an array of items for the template. This is used throughout SMF.
- $options - an array of all the theme options defined by the user
- $modSettings - an array holding all the management settings defined in the database table smf_settings
- $scripturl - a string which holds the URL to the script. Used to build links to be displayed in the templates. Please refrain from using relative URLs.
- $settings - an array of all the global theme settings
- $smcFunc - array of functions for general use.
- $sourcedir - a string containing the absolute path to the Sources directory. Useful for including source files.
- $user_info - an array containing all the information about the current logged user.
Boards, topics, and posts
- $attachments - an array holding all the info for attachments and is seen primarily in Display.php and largely processed in displayAttachmentContext().
- $board - an integer containing the current board's ID and is seen in most of the files for displaying posts and boards.
- $board_info - an array which contains all the information required to display a board.
- $topic - an integer containing the current topic's ID and is seen in most of the files for displaying posts and boards.
- $topic_info - an array which contains all the information required to display a topic and all the posts therein.