User Tools

Site Tools


Get Familiar With LiteCart's Components

Coding 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.

Folder Structure

In the early era of LiteCart, we adapted a directory layout that reminded 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 a future version will come with a new fresh directory structure.

├── 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/
Admin apps
Dashboard widgets
Cache Directory
Data Storage


Class templates
Entity Objects
Defined functions called via using functions::name()
System nodes and events
Read-only factory model reference objects
URL routing and resolving
HTML and Output
Service Layers and Clients
Installation wizard
Application logs


Folder Referencing

LiteCart uses two ways for referencing a folder. A server side system path (FS_), or a client side web path (WS_).

The system path for the application is FS_DIR_APP and is translated to something similar like /home/you/public_html/. System paths are used for referencing a file or directory on the server side.

The web path for the application is WS_DIR_APP and is translated to something like /. Web paths are used for referencing a file or directory on the browser end.

System Nodes / Library

The very core of LiteCart contains of a set of system nodes that are the arms of the platfrom. Think of it as an octopus where each limb is a system node. The main purpose of a system node is to hold and process information upon certain stated events, or provide helper functions or references.

LiteCart's JIT designed framework makes the platform super fast. Once you are accessing a node, LiteCart will automatically load the necessary php files into the system.

The system nodes are static classes. They are accessed by simply typing nodename::methodname() or nodename::$variablename.

The following command will load the database component ~/includes/library/, initate it, set up some system events, and return a result from the command:


Database Connections

A connection to the default database is opened automatically when needed by a query.

To make a MySQL query request and fetching the results:

$query = database::query(
  "select * ..."

while ($row = database::fetch($query)) {

Helper Functions

No need to keep track of included function files. Functions are dynamically loaded through the system node called functions.

Note: All functions must be stored in ~/includes/functions/. The filename must be preceeded by the preifx “func_”. The function name must begin with the filename without the prefix. Example: would host all functions named form_something().

To load ~/includes/functions/ (if not previously loaded) and call form_draw_textarea():


Entity Objects

Entity objects are class objects that control object data and their mappings to the database. By initiating an entity PHP will autoload the required file for you.

To create a new product and give it an english name:

$product = new ent_product();
$product->data['name']['en'] = 'Test product';

To update the email address for customer id 34:

$customer = new ent_customer(34);
$customer->data['email'] = '';

Reference Objects

Reference objects are a factory read-only class model that can return partial parts of entity data without wasting unecessary resources.

Access the database and output the english product name for a product:

$product = new ref_product(id);
echo $product->name;


echo reference::product(id)->name;

Internal links are for logical pages of the platform e.g. products, categories, customer service, etc.

To redirect to the product page (meaning pages/ for product id 1234 use document::ilink():

header('Location: ' . document::ilink('product', array('product_id' => 1234)));

To redirect to an external file e.g. images use document::link():

header('Location: ' . document::link(WS_DIR_APP . 'images/myimage.png'));

When special characters are not allowed, i.e. inside HTML element parameters use document::href_link():

<a href="<?php echo document::href_link(WS_DIR_APP . 'search.php')); ?>">My link</a>


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.

To output a translation for title_hello_world and inject an english translation to the database (if not previously injected):

echo language::translate('title_hello_world', 'Hello World'); 

Template Layouts

The document library module holds global snippets of content that are output to placeholders in a layout or view file. Any placeholders that do not have snippet content will be removed before output to browser.

To store a global snippet named foo_bar:

document::$snippets['foo_bar'] = '<h1>Foo bar!</h1>';

To insert a placeholder for the snippet content in a page layout file:


Then, to change layout file for the output to ~/includes/templates/my_template.catalog/layouts/

document::$layout = 'my_layout';

Template Views

LiteCart tries to separate logic from the design by the use of views.

Gather some data and pass to a view:

$my_content = new ent_view();
$my_content->snippets['helloworld'] = 'Hello World';
echo $my_content->stitch('views/myview');

The template view file includes/yourtemplate/views/ supports the following syntax:

<h1><?php echo $helloworld; ?><h1>
introduction.txt · Last modified: 2021/07/07 18:16 by tim