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 [2020/01/01 23:40]
A User Not Logged in [Get Familiar With LiteCart's Components]
introduction [2020/09/01 00:59] (current)
admin
Line 5: Line 5:
 This page will introduce you to some of the components in the LiteCart framework. Hopefully getting you a better understanding what they do and how they can be used. This page will introduce you to some of the components in the LiteCart framework. Hopefully getting you a better understanding what they do and how they can be used.
  
-Feel free to stop by the [[https://www.litecart.net/forums/|LiteCart Forums]] if you have questions.+LiteCart is a [[https://en.wikipedia.org/wiki/Just-in-time_compilation|JIT]] designed [[https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller|MVC]] framework that is designed to have as little code and files as possible we possibly can. LiteCart is not built on a third party components. This may imply a little bit of a learning curve, but we think it will be worth the effort. 
 + 
 +Feel free to step by the [[https://www.litecart.net/forums/|LiteCart Forums]] if you have questions.
 ====== Folder Structure ====== ====== Folder Structure ======
  
Line 54: Line 56:
   Partials   Partials
   Entity Objects   Entity Objects
-  Defined functions called via lib_func.inc.php using functions::name()+  Helper functions
   Libraries and system nodes   Libraries and system nodes
   Modules   Modules
-  Read-only factory model reference objects+  Read-only factory model reference objects to access entities
   Route mapping   Route mapping
-  HTML and Output+  Views for HTML and Output
   Service Layers and Clients   Service Layers and Clients
   Installation wizard   Installation wizard
   Application logs   Application logs
-  Web Pages+  Controllers for web pages
      
      
-  Modifications+  vQmod Modifications
 </columns> </columns>
  
Line 86: Line 88:
  
 <file php> <file php>
-<img src="<?php echo document::href_link(WS_DIR_APP . 'images/logotype.png'); ?>" />+<img src="<?php echo document::link(WS_DIR_IMAGES . 'logotypepng'); ?>" />
 </file> </file>
-===== Library =====+===== Library Modules =====
  
-The core of LiteCart contains of a set of system nodes called library. They are loaded automatically once requested and do not have a prefix for their class names.+The core of LiteCart contains of a set of system nodes stored in includes/library/. They are loaded automatically once requested and lack a prefix for their defined class names. This is the hear of LiteCart as these are the very central components of.
  
-The main purpose of these nodes is to hold and process niched data. E.g. lib_language holds and maintains everything language related.+The main purpose of these nodes is to hold and process niched data. E.g. lib_language holds and processes anything language related.
  
 To get the session currency maintained by ~/includes/library/lib_currency.inc.php: To get the session currency maintained by ~/includes/library/lib_currency.inc.php:
Line 124: Line 126:
 ===== Entity Objects ===== ===== Entity Objects =====
  
-Entity objects are class objects that control entity data and the mappings to their storage e.g. 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.+Entity objects are class objects that control entity data and the mappings to their storage e.g. the database. By instantiating an entity object LiteCart will autoload the file constructing the object i.e. includes/entities/ent_product.inc.php and perform all the database queries needed for you.
  
 To create a new product and give it an english name: To create a new product and give it an english name:
Line 133: Line 135:
 </file> </file>
  
-To load customer 34 and update the email address:+To load customer ID 34 and update the email address:
 <file>$customer = new ent_customer(34); <file>$customer = new ent_customer(34);
 $customer->data['email'] = 'user@domain.com'; $customer->data['email'] = 'user@domain.com';
Line 140: Line 142:
 Please note prior to LiteCart 2.2.0 entity objects used the prefix ctrl_ instead of ent_. Please note prior to LiteCart 2.2.0 entity objects used the prefix ctrl_ instead of ent_.
  
-===== Reference Objects ===== 
- 
-Reference objects are **read-only** class objects that can dynamically **return partial parts of a data set**. 
- 
-The reference objects are of factory design. They do not possess a whole set of data, but fetches it for you once requested. 
- 
-Access the database and output the english product name for a product: 
- 
-<file>$product = new ref_product(id); 
-echo $product->name;</file> 
- 
-Or 
- 
-<file>echo reference::product(id)->name;</file> 
 ===== Internal Links ===== ===== Internal Links =====
  
-Internal links are created using document::ilink(). LiteCart will take care of all the logic such as adding a language prefix or rewriting the URL to a more friendly name. If used in an anchor href attribute use href_ilink() to escape special characters. +To redirect to a product page (found in pages/product.inc.php) use document::ilink():
- +
-To redirect to the product page of product 1234:+
  
 <file>header('Location: ' . document::ilink('product', array('product_id' => 1234))); <file>header('Location: ' . document::ilink('product', array('product_id' => 1234)));
 exit;</file> exit;</file>
  
-This will point to the resource at pages/product.inc.php. 
 ===== External Links ===== ===== External Links =====
  
-External links can be created using document::link(). LiteCart will then not prepend any logic to the URL such as language. When special characters are not allowed, i.e. inside HTML elements use document::href_link():+To redirect to an external file e.g. images use document::link()
 + 
 +<file>header('Location:document::link(WS_DIR_APP 'images/myimage.png')); 
 +exit;</file> 
 + 
 +When special characters are not allowed, i.e. inside HTML element parameters use document::href_link():
  
-<file><img src="<?php echo document::href_link(WS_DIR_APP . 'images/myimage.png')); ?>" /></file>+<file><a href="<?php echo document::href_link(WS_DIR_APP . 'images/myimage.png')); ?>">See Image</a></file>
      
 ===== Translations ===== ===== Translations =====
  
-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.+For best convenience we are not using external files for storing translations. Instead we store them straight in the database. Anything that isn't already translatable inside the entity object (e.g. product description) 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.+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. The default translation also functions as fallback if none is returned from the database.
  
-English is always the framework language and default translation. If translations are missing for any other languages an english translation will be returned.+English is always the framework language and language used for default translations. 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):
  
 <file>echo language::translate('title_hello_world', 'Hello World'); </file> <file>echo language::translate('title_hello_world', 'Hello World'); </file>
 +
 +===== Reference Objects =====
 +
 +Reference objects are **read-only** class objects that can dynamically **return partial parts of a data set**.
 +
 +The reference objects are of factory design. They do not possess a whole set of data, but fetches it for you once requested.
 +
 +Access the database and output the english product name for a product:
 +
 +<file>$product = new ref_product(id);
 +echo $product->name;</file>
 +
 +Or
 +
 +<file>echo reference::product(id)->name;</file>
  
 ===== Template Layouts ===== ===== Template Layouts =====
Line 198: Line 203:
  
 ===== Template Views ===== ===== Template Views =====
- 
  
 LiteCart tries to separate logic from the user interface code by the use of views. LiteCart tries to separate logic from the user interface code by the use of views.
Line 204: Line 208:
 Gather some data and pass to a view: Gather some data and pass to a view:
  
-<file php pages/mydoc.inc.php>$my_content = new view();+<file>$my_content = new view();
 $my_content->snippets['helloworld'] = 'Hello World'; $my_content->snippets['helloworld'] = 'Hello World';
-echo $my_content->stitch('pages/mydoc');</file>+echo $my_content->stitch('views/myview');</file>
  
-This is how data can be picked up in the view:+The template view file includes/yourtemplate/views/myview.inc.php supports the following syntax:
  
-<file php includes/templates/*/pages/mydoc.inc.php> +<file><h1>{snippet:helloworld}<h1> 
-<h1>{snippet:helloworld}<h1> +<h1><?php echo $helloworld; ?><h1></file>
-<p><?php echo $helloworld; ?><p></file>+
introduction.1577918448.txt.gz · Last modified: 2020/01/01 23:40 by A User Not Logged in