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/08/28 18:47]
162.158.134.232 [Template Layouts]
introduction [2020/01/01 23:40] (current)
172.68.191.51 [Get Familiar With LiteCart's Components]
Line 1: Line 1:
-====== Get Familiar With LiteCart Components ======+====== Get Familiar With LiteCart'​s ​Components ======
  
-===== Library Modules =====+Coding with LiteCart is fun. And it's even more fun when you can do great things with the smallest amount of code.
  
-The core of LiteCart contains of a set of system nodes called library. They are loaded automatically once requested and lack a prefix for their class names.+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. 
 +====== Folder Structure ====== 
 + 
 +<columns 100% 25% -> 
 +<​code>​ 
 +
 +├── admin/ 
 +│   ​├── *.app/ 
 +│   ​└── *.widget/ 
 +├── cache/ 
 +├── data/ 
 +├── ext/ 
 +│   ​├── jquery/ 
 +│   ​└── ... 
 +├── images/ 
 +├── includes/ 
 +│   ​├── abstracts/​ 
 +│   ​├── boxes/ 
 +│   ​├── entities/ 
 +│   ​├── functions/​ 
 +│   ​├── library/ 
 +│   ​├── modules/ 
 +│   ​├── references/​ 
 +│   ​├── routes/ 
 +│   ​├── templates/​ 
 +│   ​└── wrappers/ 
 +├── install/ 
 +├── logs/ 
 +├── pages/ 
 +└── vqmod/ 
 +    ├── vqcache/ 
 +    └── xml/ 
 +</​code>​ 
 + 
 +<​newcolumn>​ 
 +  Application Root 
 +  Backend 
 +  Admin apps 
 +  Dashboard widgets 
 +  Cache Directory 
 +  Data Storage 
 +  External/​Extras/​Vendor 
 +   
 +   
 +  Graphics 
 +   
 +  Class templates 
 +  Partials 
 +  Entity Objects 
 +  Defined functions called via lib_func.inc.php using functions::​name() 
 +  Libraries and system nodes 
 +  Modules 
 +  Read-only factory model reference objects 
 +  Route mapping 
 +  HTML and Output 
 +  Service Layers and Clients 
 +  Installation wizard 
 +  Application logs 
 +  Web Pages 
 +   
 +   
 +  Modifications 
 +</​columns>​ 
 + 
 +Please note the folder structure is subject to change in a future version. 
 + 
 +===== Paths ===== 
 + 
 +When defining files and locations you will come a cross two directory definitions:​ 
 + 
 +**FS_DIR_APP** 
 +The file system path to the application root directory e.g. /​home/​john/​public_html/​litecart/​. Used to reference a file on the server side. 
 + 
 +**WS_DIR_APP** 
 +The web system path to the application root directory e.g. /litecart/. Used to reference a resource in the web interface on the client side. 
 + 
 +<file php> 
 +file_get_contents(FS_DIR_APP . '​subfolder/​myfile.ext'​);​ 
 +</​file>​ 
 + 
 +<file php> 
 +<img src="<?​php echo document::​href_link(WS_DIR_APP . '​images/​logotype.png'​);​ ?>" /> 
 +</​file>​ 
 +===== Library ===== 
 + 
 +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 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 maintains everything language related.
Line 29: Line 116:
  
 No need to keep track of included function files. Functions can be dynamically loaded through the system library module. This means the files defining the functions will be loaded once the functions are requested. No need to keep track of included function files. Functions can be dynamically loaded through the system library module. This means the files defining the functions will be loaded once the functions are requested.
- 
-Note: All function names must be begin with the file basename and be stored in ~/​includes/​functions/​. 
  
 To load ~/​includes/​functions/​func_form.inc.php (if not previously loaded) and output a textarea: To load ~/​includes/​functions/​func_form.inc.php (if not previously loaded) and output a textarea:
Line 36: Line 121:
 <​file><?​php echo functions::​form_draw_textarea('​foo'​);​ ?></​file>​ <​file><?​php echo functions::​form_draw_textarea('​foo'​);​ ?></​file>​
  
 +Note: All function names must be begin with the prefix func_ and be stored in ~/​includes/​functions/​.
 ===== Entity Objects ===== ===== Entity Objects =====
  
-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.+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.
  
 To create a new product and give it an english name: To create a new product and give it an english name:
Line 57: Line 143:
  
 Reference objects are **read-only** class objects that can dynamically **return partial parts of a data set**. 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: Access the database and output the english product name for a product:
Line 68: Line 156:
 ===== Internal Links ===== ===== Internal Links =====
  
-To redirect to a product page (found in pages/​product.inc.php) use document::​ilink():​+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 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 =====
  
-To redirect to an external file e.g. images use document::​link()+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():​
- +
-<​file>​header('​Location:​ ' ​document::​link(WS_DIR_IMAGES ​'​myimage.png'​));​ +
-exit;</​file>​ +
- +
-When special characters are not allowed, i.e. inside HTML element parameters ​use document::​href_link():​+
  
-<​file><​a href="<?​php echo document::​href_link(WS_DIR_IMAGES ​. '​myimage.png'​));​ ?>">See Image</a></​file>​+<​file><​img src="<?​php echo document::​href_link(WS_DIR_APP ​. 'images/myimage.png'​));​ ?>" /></​file>​
   ​   ​
 ===== Translations ===== ===== Translations =====
Line 114: Line 200:
  
  
-LiteCart tries to separate logic from the design ​by the use of views.+LiteCart tries to separate logic from the user interface code by the use of views.
  
 Gather some data and pass to a view: Gather some data and pass to a view:
  
-<​file>​$my_content = new view();+<​file ​php pages/​mydoc.inc.php>​$my_content = new view();
 $my_content->​snippets['​helloworld'​] = 'Hello World';​ $my_content->​snippets['​helloworld'​] = 'Hello World';​
-echo $my_content->​stitch('​views/myview'​);</​file>​+echo $my_content->​stitch('​pages/mydoc'​);</​file>​
  
-The template view file includes/​yourtemplate/​views/​myview.inc.php supports ​the following syntax:+This is how data can be picked up in the view:
  
-<​file><​h1>​{snippet:​helloworld}<​h1>​ +<​file ​php includes/​templates/​*/​pages/​mydoc.inc.php> 
-<h1><?​php echo $helloworld;​ ?><h1></​file>​+<​h1>​{snippet:​helloworld}<​h1>​ 
 +<p><?​php echo $helloworld;​ ?><p></​file>​
introduction.1567010843.txt.gz · Last modified: 2019/08/28 18:47 by 162.158.134.232