Templates examples ( lib/template.php )
Creating object
Load function
Replace function
Instance function
Lock/Unlock functions
Display function
Creating object
Description
To work with templates you need to create template object. When you write code in "modules/some_filename.php" you already have template object $t with loaded content from "modules/templates/some_filename.html".
PHP code
To work with templates you need to create template object. When you write code in "modules/some_filename.php" you already have template object $t with loaded content from "modules/templates/some_filename.html".
PHP code
Load function
Description
This function loads html template from "templates" folder. if true value is added as last parametr $some_template->load("modules/templates/some_name.html",true); template will be loaded from "modules/templates" folder.
PHP code
This function loads html template from "templates" folder. if true value is added as last parametr $some_template->load("modules/templates/some_name.html",true); template will be loaded from "modules/templates" folder.
PHP code
Replace function
Description
This function finds all <key:entered_key> keys and replace them by entered value
$some_template->replace($some_key,$some_value); Example 1
2012-02-09 15:08:04
HTML code PHP code
Example 2
HTML code PHP code
This function finds all <key:entered_key> keys and replace them by entered value
$some_template->replace($some_key,$some_value); Example 1
2012-02-09 15:08:04
HTML code PHP code
Example 2
this DIV is located in tmp.html
HTML code PHP code
Instance function
Description
Function display will clean all <sub:name></sub:name> constructions. Function instance copies html code from <sub:name></sub:name> constructions and pastes before <sub:name></sub:name> construction. So when function display is runned this part of html code will be shown in browser.
In 2 words - shows sub`s.
Example
HTML code PHP code
Function display will clean all <sub:name></sub:name> constructions. Function instance copies html code from <sub:name></sub:name> constructions and pastes before <sub:name></sub:name> construction. So when function display is runned this part of html code will be shown in browser.
In 2 words - shows sub`s.
Example
HTML code PHP code
Lock/Unlock functions
Description
These 2 functions are always used together. Idea is mostly same as in "instance" function but now we are locking in part of html code between <sub:name></sub:name> construction using "lock" function and all functions that we run after that will affect only this part of html code. And when function unlock is runned it's pastes this html code before <sub:name></sub:name> construction.
In few words - allows to show part of code many times filled with different values using one <sub:name></sub:name> construction
Example 1 (database required)
HTML code PHP code
Example 2
HTML code PHP code
These 2 functions are always used together. Idea is mostly same as in "instance" function but now we are locking in part of html code between <sub:name></sub:name> construction using "lock" function and all functions that we run after that will affect only this part of html code. And when function unlock is runned it's pastes this html code before <sub:name></sub:name> construction.
In few words - allows to show part of code many times filled with different values using one <sub:name></sub:name> construction
Example 1 (database required)
| 9 | Ano | ano@nymo.us | 76543210 |
| 3 | Tester | tester@gmail.com | 55055055 |
HTML code PHP code
Example 2
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
| 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 |
| 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 |
| 5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 |
| 6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 | 54 | 60 |
| 7 | 14 | 21 | 28 | 35 | 42 | 49 | 56 | 63 | 70 |
| 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 |
| 9 | 18 | 27 | 36 | 45 | 54 | 63 | 72 | 81 | 90 |
| 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 |
HTML code PHP code
Display function
Description
this function removes all <sub:name></sub:name> and <key:name> constructions from template and shows it in browser.
PHP code
this function removes all <sub:name></sub:name> and <key:name> constructions from template and shows it in browser.
PHP code
Database examples ( lib/mysql.php )
Connection
Function Q
Function AQ
Function Q2
Connection
Description
Just enter host, login, pass, db_name in "lib/password.php".
PHP code
Just enter host, login, pass, db_name in "lib/password.php".
PHP code
Function Q
Description
this function sends sql query and returns simple 2X array from database. ( $data[0][0] )
PHP code
this function sends sql query and returns simple 2X array from database. ( $data[0][0] )
PHP code
Function AQ
Description
this function sends sql query and returns assoc array from database. ( $data[0][id] )
PHP code
this function sends sql query and returns assoc array from database. ( $data[0][id] )
PHP code
Function Q2
Description
this function sends sql query and returns number of affected rows. ( 1 )
PHP code
this function sends sql query and returns number of affected rows. ( 1 )
PHP code
this DIV is located in tmp.html
Copyright © 2010 Apycom jQuery Menus