Introduction
Pavadinimas
Jokių pakeitimųPermalink
Jokių pakeitimųTurinys
| Old | New | ||
|---|---|---|---|
| 1 | # Get Familiar With LiteCart's Components | 1 | # Get Familiar With LiteCart's Components |
| 2 | 2 | ||
| 3 | Coding with LiteCart is fun | 3 | Coding with LiteCart is fun! But getting started learning a new platform can be hard work if you don't know where to look. On this page we have gathered some notable information that will help you understand the platform just a little better. |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | ## Folder Referencing | 6 | ## Folder Referencing |
| 33 | 33 | ||
| 34 | ## Folder Structure | 34 | ## Folder Structure |
| 35 | 35 | ||
| 36 | In the early | 36 | In the early days of LiteCart, we adapted a directory layout that was reminiscent of osCommerce. We specifically targeted osCommerce users for migrating to LiteCart and they needed a folder structure they could recognize. That is no longer the case and LiteCart 3.0 comes with a fresh, new directory structure. |
| 37 | 37 | ||
| 38 | This is the current folder structure as of LiteCart 2.3+: | 38 | This is the current folder structure as of LiteCart 2.3+: |
| 39 | 39 | ||
| 71 | 71 | ||
| 72 | ## System Nodes / Library | 72 | ## System Nodes / Library |
| 73 | 73 | ||
| 74 | The very core of LiteCart con | 74 | The very core of LiteCart consists of a set of system nodes that are the "arms" of the platform. Think of it as an octopus where each limb is a system node. Each node is specialized for a specific purpose (e.g. language, currency, database, etc.). The main purpose of a system node is to hold and process information, and it can respond to certain stated events. |
| 75 | 75 | ||
| 76 | LiteCart's on-demand designed framework makes the platform super fast! Once you are accessing a node, LiteCart will automatically load only the necessary | 76 | LiteCart's on-demand designed framework makes the platform super fast! Once you are accessing a node, LiteCart will automatically load only the necessary PHP files into the system. |
| 77 | 77 | ||
| 78 | The system nodes are static classes. They are accessed by simply typing nodename::method() or nodename::$variable. | 78 | The system nodes are static classes. They are accessed by simply typing nodename::method() or nodename::$variable. |
| 79 | 79 | ||
| 80 | The following command will load the language component ~/includes/library/lib_language.inc.php, initiate it, detect the language to be used, set up some application events, and collect a result from the database and return it | 80 | The following command will load the language component ~/includes/library/lib_language.inc.php, initiate it, detect the language to be used, set up some application events, and collect a result from the database and return it — all from commands like: |
| 81 | 81 | ||
| 82 | ```php | 82 | ```php |
| 83 | echo language::translate('title_hello_world', 'Hello World'); | 83 | echo language::translate('title_hello_world', 'Hello World'); |
| 95 | 95 | ||
| 96 | A connection to the default database is opened automatically when needed by a query. | 96 | A connection to the default database is opened automatically when needed by a query. |
| 97 | 97 | ||
| 98 | To make a MySQL query request and fetch | 98 | To make a MySQL query request and fetch the results, the standard procedure is as follows: |
| 99 | 99 | ||
| 100 | ```php | 100 | ```php |
| 101 | $query = database::query( | 101 | $query = database::query( |
| 102 | " | 102 | "SELECT * FROM ". DB_TABLE_PREFIX ."mytable |
| 103 | | 103 | ORDER BY `id`;" |
| 104 | ); | 104 | ); |
| 105 | 105 | ||
| 106 | while ($row = database::fetch($query)) { | 106 | while ($row = database::fetch($query)) { |
| 115 | 115 | ||
| 116 | No need to keep track of included function files. Functions are dynamically loaded when needed through the system node found in lib_functions.inc.php. | 116 | No need to keep track of included function files. Functions are dynamically loaded when needed through the system node found in lib_functions.inc.php. |
| 117 | 117 | ||
| 118 | All helper functions are stored in ~/includes/functions/. The filenames are preceeded by the preifx "func_". The name of the functions must begin with the collection name. Example: func_form.inc.php would host all helper functions named | 118 | All helper functions are stored in ~/includes/functions/. The filenames are preceeded by the preifx "func_". The name of the functions must begin with the collection name. Example: func_form.inc.php would host all helper functions named `form_something()`. |
| 119 | 119 | ||
| 120 | To load ~/includes/functions/form.inc.php (if not previously loaded) and call form_draw_textarea(): | 120 | To load ~/includes/functions/form.inc.php (if not previously loaded) and call form_draw_textarea(): |
| 121 | 121 | ||
| 146 | 146 | ||
| 147 | ## Reference Objects | 147 | ## Reference Objects |
| 148 | 148 | ||
| 149 | Reference objects are a factory designed **read-only** class model that can **return partial parts of entity data** without wasting unnecessary resources. This means only the queries necessary will be made to the database. | 149 | Reference objects are a factory designed, **read-only** class model that can **return partial parts of entity data** without wasting unnecessary resources. This means only the queries necessary will be made to the database. |
| 150 | 150 | ||
| 151 | Access the database and output the English product name for a product: | 151 | Access the database and output the English product name for a product: |
| 152 | 152 | ||
| 155 | echo $product->name; | 155 | echo $product->name; |
| 156 | ``` | 156 | ``` |
| 157 | 157 | ||
| 158 | 158 | or simply: | |
| 159 | 159 | ||
| 160 | ```php | 160 | ```php |
| 161 | echo reference::product($id)->name; | 161 | echo reference::product($id)->name; |
| 162 | ``` | 162 | ``` |
| 163 | 163 | ||
| 164 | Not all entity objects are available as reference objects. When they | 164 | Not all entity objects are available as reference objects. When they're not, LiteCart will fallback to extracting the data from the entity object by the same name. Here we access the an order through the reference node although there is no file ref_order.inc.php: |
| 165 | 165 | ||
| 166 | ```php | 166 | ```php |
| 167 | reference::order($id)->customer['company']; | 167 | reference::order($id)->customer['company']; |
| 224 | 224 | ||
| 225 | ## Translations | 225 | ## Translations |
| 226 | 226 | ||
| 227 | For your | 227 | For your convenience, we store translations in the database. While fetching a translation, you can insert a default translation, if not previously stored. This is done by providing the first default translation right in the code. English is used as the framework language and default translation. If translations are missing for any other languages, an English translation will be returned. |
| 228 | 228 | ||
| 229 | To output a translation for title_hello_world and inject an English translation to the database (if not previously injected): | 229 | To output a translation for title_hello_world and inject an English translation to the database (if not previously injected): |
| 230 | 230 | ||
| 262 | 262 | ||
| 263 | LiteCart tries to separate logic from the design by the use of views. | 263 | LiteCart tries to separate logic from the design by the use of views. |
| 264 | 264 | ||
| 265 | 265 | Views gather data (called snippets) and pass them to a page for stitching together: | |
| 266 | 266 | ||
| 267 | ```php | 267 | ```php |
| 268 | $my_content = new ent_view(); | 268 | $my_content = new ent_view(); |
| 280 | 280 | ||
| 281 | ## Virtual Modifications | 281 | ## Virtual Modifications |
| 282 | 282 | ||
| 283 | LiteCart has a built-in virtual modification system called vMod | 283 | LiteCart has a built-in virtual modification system called vMod, which was developed exclusively for LiteCart. |
| 284 | 284 | ||
| 285 | Wrap all included | 285 | Wrap all included PHP scripts with vmod::check(). It will check if there is a virtual modification, apply it to the source code, then return the modified script for inclusion. |
| 286 | 286 | ||
| 287 | ```php | 287 | ```php |
| 288 | include vmod::check(FS_DIR_APP . 'includes/directory/file.inc.php'); | 288 | include vmod::check(FS_DIR_APP . 'includes/directory/file.inc.php'); |
Edited by s22_tech on 17 rugs. 2024 at 22:22