Introduction

Pavadinimas

Jokių pakeitimų

Permalink

Jokių pakeitimų

Turinys

OldNew
1# Get Familiar With LiteCart's Components 1# Get Familiar With LiteCart's Components
2 2
3Coding with LiteCart is fun. But setting yourself into 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 find and understand the platform just a little better. 3Coding 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
36In the early era 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. 36In 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
38This is the current folder structure as of LiteCart 2.3+: 38This is the current folder structure as of LiteCart 2.3+:
39 39
71 71
72## System Nodes / Library 72## System Nodes / Library
73 73
74The very core of LiteCart contains 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 on a specific thing (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. 74The 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
76LiteCart'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. 76LiteCart'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
78The system nodes are static classes. They are accessed by simply typing nodename::method() or nodename::$variable. 78The system nodes are static classes. They are accessed by simply typing nodename::method() or nodename::$variable.
79 79
80The 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 the command: 80The 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
83echo language::translate('title_hello_world', 'Hello World'); 83echo language::translate('title_hello_world', 'Hello World');
95 95
96A connection to the default database is opened automatically when needed by a query. 96A connection to the default database is opened automatically when needed by a query.
97 97
98To make a MySQL query request and fetching the results, the standard procedure is the following: 98To 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 "select * from ". DB_TABLE_PREFIX ."mytable 102 "SELECT * FROM ". DB_TABLE_PREFIX ."mytable
103 order by id;" 103 ORDER BY `id`;"
104); 104);
105 105
106while ($row = database::fetch($query)) { 106while ($row = database::fetch($query)) {
115 115
116No need to keep track of included function files. Functions are dynamically loaded when needed through the system node found in lib_functions.inc.php. 116No 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
118All 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(). 118All 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
120To load ~/includes/functions/form.inc.php (if not previously loaded) and call form_draw_textarea(): 120To 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
149Reference 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. 149Reference 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
151Access the database and output the English product name for a product: 151Access the database and output the English product name for a product:
152 152
155echo $product->name; 155echo $product->name;
156``` 156```
157 157
158Or 158or simply:
159 159
160```php 160```php
161echo reference::product($id)->name; 161echo reference::product($id)->name;
162``` 162```
163 163
164Not all entity objects are available as reference objects. When they are 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: 164Not 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
167reference::order($id)->customer['company']; 167reference::order($id)->customer['company'];
224 224
225## Translations 225## Translations
226 226
227For your best convenience we are storing 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 straight in the code. English is always the framework language and default translation. If translations are missing for any other languages, an English translation will be returned. 227For 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
229To output a translation for title_hello_world and inject an English translation to the database (if not previously injected): 229To output a translation for title_hello_world and inject an English translation to the database (if not previously injected):
230 230
262 262
263LiteCart tries to separate logic from the design by the use of views. 263LiteCart tries to separate logic from the design by the use of views.
264 264
265Gather some data (called snippets) and pass them to a view for stitching together: 265Views 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
283LiteCart has a built-in virtual modification system called vMod. Developed exclusively for LiteCart. 283LiteCart has a built-in virtual modification system called vMod, which was developed exclusively for LiteCart.
284 284
285Wrap 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. 285Wrap 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
288include vmod::check(FS_DIR_APP . 'includes/directory/file.inc.php'); 288include vmod::check(FS_DIR_APP . 'includes/directory/file.inc.php');

Edited by s22_tech on 17 rugs. 2024 at 22:22

View code on GitHub