User Tools

Site Tools


introduction

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
introduction [2019/05/05 21:35]
172.69.138.16 [Object Controllers]
introduction [2019/06/12 04:39] (current)
admin [Translations]
Line 1: Line 1:
 ====== Get Familiar With LiteCart Components ====== ====== Get Familiar With LiteCart Components ======
  
-===== System Model =====+===== Library Modules ​=====
  
-The system ​core of LiteCart contains of a set of library modules or system nodes that are loaded automatically ​upon page load. The main purpose of a system node is to hold and process information upon certain stated events.+The core of LiteCart contains of a set of system nodes called library. They are loaded automatically ​once requested and lack prefix for their class names.
  
-To call the query() class method defined in ~/​includes/​library/​lib_database.inc.php: +The main purpose of these nodes is to hold and process niched data. E.g. lib_language holds and maintains everything language related. 
-<​file>​database::query(...)</​file>​ + 
-    ​+To get the session currency maintained by ~/​includes/​library/​lib_currency.inc.php: 
 +<​file ​php>currency::$selected['​code'​]</​file>​ 
 + 
 +To change the session currency: 
 +<file php>​currency::​set('​EUR'​)</​file>​
 ===== Database ===== ===== Database =====
  
-A connection to the default database is opened only when first needed.+The lib_database library module handles all database activity. ​A connection to the default database is opened only when first needed.
  
-To pass a MySQL query and fetch the results:+To perform ​a MySQL query and fetch the results:
  
 <​file>​$query = database::​query( <​file>​$query = database::​query(
Line 32: Line 36:
 <​file>​functions::​form_draw_textarea()</​file>​ <​file>​functions::​form_draw_textarea()</​file>​
   ​   ​
-===== Entity ​Controllers ​=====+===== Entity ​Objects ​=====
  
-Object controllers ​are class objects that control ​object ​data and their mappings to the database. By initiating a class PHP will autoload the file for you.+Entity objects ​are class objects that control ​entity ​data and the mappings to the database. By instantiating an entity object LiteCart ​will autoload the file constructing the class i.e. includes/​entities/​ent_product.inc.php and perform all the database queries ​for you.
  
 To create a new product and give it an english name: To create a new product and give it an english name:
  
-<​file>​$product = new ctrl_product();+<​file>​$product = new ent_product();
 $product->​data['​name'​]['​en'​] = 'Test product';​ $product->​data['​name'​]['​en'​] = 'Test product';​
 $product->​save();​ $product->​save();​
 </​file>​ </​file>​
  
-To update the email address ​for customer id 34+To load customer 34 and update the email address: 
-<​file>​$customer = new ctrl_customer(34);+<​file>​$customer = new ent_customer(34);
 $customer->​data['​email'​] = '​user@domain.com';​ $customer->​data['​email'​] = '​user@domain.com';​
 $customer->​save();</​file>​ $customer->​save();</​file>​
 +
 +Please note prior to LiteCart 2.2.0 entity objects used the prefix ctrl_ instead of ent_.
  
 ===== Reference Objects ===== ===== Reference Objects =====
Line 60: Line 66:
  
 <​file>​echo reference::​product(id)->​name;</​file>​ <​file>​echo reference::​product(id)->​name;</​file>​
- +===== Internal Links =====
-<meta name = "​msvalidate.01"​ content = "​4F5259541DE17AA289BFBAA6CAE11817"​ />===== Internal Links =====+
  
 To redirect to a product page (found in pages/​product.inc.php) use document::​ilink():​ To redirect to a product page (found in pages/​product.inc.php) use document::​ilink():​
Line 81: Line 86:
 ===== Translations ===== ===== Translations =====
  
-For 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.+For convenience we are storing translations in the database. ​Anything that isn't already maintained by an entity object is handled by the language library module. 
 + 
 +While fetching a translation you can inject ​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.
  
 To output a translation for title_hello_world and inject an english translation to the database (if not previously injected): To output a translation for title_hello_world and inject an english translation to the database (if not previously injected):
introduction.1557084917.txt.gz · Last modified: 2019/05/05 21:35 by 172.69.138.16