In phpMySport, the PHP development is separated from the HTML design. Thus, the application can be personalized according to the colors and layout desired by the user. This is possible thanks to a "template" system. There are a set of files containing PHP code and other "template" files which are related to HTML pages containing template code. Having loaded a web page, the application then reads the HTML files and replaces the template code with the corresponding PHP variable values.
The different designs are situated in the "template" directory. Each design is composed of a directory of HTML files, ordered by module. An initial design is provided with phpMySport, named the "defaut" template.
Here are the details of the template code.
Three types of information can be displayed on a page: static information like text, cyclic information as in lists and option information.
Three template codes are thus required. Each is associated with a PHP variable type: text (string) for static data, tables (array) for lists and a boolean of options.
The gathering of information for display is held in a single and unique variable: $page. This is a two-dimensional table that contains the set of text, tables and booleans needed by a page.
A PHP function is used in the "index.php" file to set this $page variable and the template file defined to create the final HTML code seen by the user.
The basic code is used to display a PHP variable of type "text".
The name of the variable is placed within a pair of "{" and "}" symbols.
|
Template
code |
PHP
code |
Displayed on the screen |
|---|---|---|
|
{my_text} |
$page['my_text'] = "My text" |
My text |
Lists are used to display a PHP variable of "array" type. The key word "LOOP" is used to signify that a variable corresponds to a set. All the HTML code held within "LOOP" and "END LOOP" will be repeated as many times as the table has lines.
|
Template code |
PHP code |
Displayed on the screen |
|---|---|---|
|
<!-- LOOP my_list -->
|
$page['my_list']=array( |
Durant Martin
Dupond Marie |
The option code is used for boolean variables or more precisely "true / false" values. If the variable is empty, then the HTML code within the two "OPTION" tags will not be visible. Otherwise it will be displayed.
|
Template code |
PHP code |
Displayed on the screen |
|---|---|---|
|
<!-- OPTION var1 -->
<!-- OPTION var2 -->
|
$page['text1']="Text 1";
$page['var1']=""; |
Text 2 |
To personalize the design of phpMySport and display it in your club’s colors, you will need to create your own template. This is relatively quick, but it is preferable to already have an understanding of the CSS and HTML languages. Here are the different steps to follow:
div#header { height:90px; width:100%; margin:0 auto; padding:0; }
div#header
{ height: 90px; width:100%;
margin:0 auto; padding:0; background:url(mon_logo.jpg) no-repeat; }
#header img { display:none };
Please do not hesitate to make known your artistic qualities and share your graphic endeavors with other phpMySport users. To do this, please send your images and personalized CSS files to us!