Developing LemonStand modules
LemonStand is a modular application. All features, including eCommerce and CMS functions are supplied by different modules. By developing your own LemonStand modules you can solve the following tasks:
- adding new features to your store
- extending existing objects, like customers or orders
- extending the Administration Area user interface by adding new tabs and forms
Anatomy of a LemonStand module
From a filesystem point of view, each module in LemonStand is a subdirectory of the modules directory. There are naming conventions, described below, which you should follow when you are choosing a name for a new module directory. A module directory can contain the following subdirectories:
- classes
- controllers
- resources
- models
- updates
The classes directory should contain a module information PHP class. The classes and updates are the only directories required for creating a simplest LemonStand module. The classes directory can contain PHP classes required for your module specific needs. Also, the classes directory should contain a module information class declaration, which is described in the [link]Developing a simple module[/link] article.
The controllers directory contains controller class files and view (HTML) files which are needed for building a module-specific user interface for the Administration Area. If you are not going to add new pages to the Administration Area, you do not need to create this directory. The process of extending the Administration Area is described in the [link]Adding a back-end user interface[link] article.
The resources directory can contain CSS, image and JavaScript files required for your module Administration Area user interface. You can create any subdirectories in this directory. You do not need to create this directory if you are not going to extend the Administration Area, or if you do not need resource files for your module.
The models directory can contain model class PHP scripts required for your module. You do not need to use model classes if your module have no tables in the database. Please read the [link]Working with the database[/link] article for details about model PHP classes.
The updates directory should contain a module version information file (version.dat) and SQL or PHP scripts required for creating and updating database tables required for your module. This subdirectory is needed even if a module have no database tables. Please read the [link]Developing a simple module[/link] and [link]Creating and updating database tables[/link] articles for details.
Naming conventions
The LemonStand programming framework applies some simple naming conventions to file and PHP class names. The conventions allow LemonStand to load PHP classes automatically without using the require() or include() PHP functions. Also, there are some naming conventions for module directory names (or module identifiers), developed in order to avoid future conflicts between modules created by different developers.
Module directories
A module directory name cannot contain spaces, underscores and minus symbols. Module directory names should be compatible with the PHP variable and class naming conventions - for example names should not begin with a digit. All file and directory names should be written in lower case. To avoid naming collisions with other future modules please add some developer-specific prefix to your module directory names, for example a company name. LemonStand native modules do not have any prefixes. Examples of correct names of module directories:
- abcblog - directory of some blog module developed by some ABC company
- xyzcart - directory of some cart extension module developed by some XYZ company
Examples of incorrect module directory names:
- abc_blog - contains the underscore symbol
- xyz-cart - contains the minus symbol
- 1xyzcart - the first character should not be a digit
- xyzCART - contains upper-case letters
PHP class names
Each class defined in a module should have a name with a prefix matching the module identifier (or a module directory name), followed with the underscore character. You can use upper-case letters in class names. Example of a correct class name: AbcBlog_ClassName. You can use any characters allowed by PHP for class names after the prefix. For example you can create a class with the following name: AbcBlog_Class_Name.
PHP class files
All PHP classes, including model classes, should be declared in separate files. A PHP class file name should match a name of a class declared in the file, and should be written in lower case. Example of a correct class file name: abcblog_classname.php. This file can contain a PHP class with the following names: AbcBlog_ClassName or AbcBlog_Classname, or other name with any combination of uppper- and lower-case characters.
Also there are some conventions for controller and view file names, but they will be described in the [link]Adding a back-end user interface[link] article.
Database table names
Database table names should be written in lower case and should have prefixes matching a module identifier, followed with the underscore character. Example of a correct table name: abcblog_posts.
Continue
- Developing a simple module - describes a process of developing a simplest LemonStand module
- Creating and updating database tables - explains how you can create or update module-specific database tables
-
Working with the database - describes methods of working with database tables and creating model classes
- Creating data relations - explains how you can organize data relations using ActiveRecord - "many to many" and "one to many"
-
Adding a back-end user interface - describes the process of adding new pages to the Administration Area
- Structure of a view document - explains the internal structure of a view document
- Partials - explains how you can re-use common page elements using the partials concept
- Standard page elements - describes the standard Administration Area page elements like breadcrumbs, toolbars, indicators and buttons
- Handling errors and displaying status messages - explains how you can throw exceptions and display error and success messages on the pages
- Extending the Administration Area menu - explains how you can add new items to the main menu and new tabs to the top menu in the Administration Area
- Using AJAX - describes how you can use AJAX in the Administration Area
-
Lists and forms in the Administration Area - describes the process of implementing lists and forms
- Lists - describes the process of implementing lists in the Administration Area
- List filters - explains how you can add the filtering feature to a list
- Forms - explains how you can create forms for adding, modifying and deleting database records
- Programming module CMS actions - explains how your modules can add new items to the CMS action list and extend the front-end website with new functions
- Using module access points - explains how you can register a module access point for invoking module features them through specific URLs
- Handling LemonStand events - explains how you can customize LemonStand by handling system events
-
Extending existing models - explains how you can add new fields to the customer, product and order models
- Extending models with related columns - explains how you can add data relations in run-time and extend existing models with columns which refer to another model
- Sending email messages - explains how you can send email messages to LemonStand customers or system administrators.
Next: Developing a simple module
Previous: Extending LemonStand
Return to Extending LemonStand
Comments
No comments posted so far.
Add your comment
Loading form...