Zen Cart extensibility
Zen Cart extensibility is the extensibility principle as it applies to Zen Cart.
See also Learning Zen Cart (1).
Plugins
...
About initSystem
The term initSystem, apart from being a tag used to group certain PHP files together in the new documentation, embraces all files that are automatically included / initialized before any command scripts can be run.
Zen Cart® v1.x uses a (non Object Oriented) page controller pattern to decide the scripts to run, based on HTTP_GET parameters.
The most important of these is the 'main_page' HTTP_GET parameter.
Depending on that parameter, a command script is then run.
Each commmand script resides in a directory in / includes / modules / pages
.
For example if main_page = login the command script would be taken from the / includes / modules / pages / login /
directory.
However the first thing every command script always does is require () the /includes/application_top.php file. This is the heart of the initSystem.
It is application_top.php
that is responsible for initialising basic subsystems (database abstraction / sessions / languages etc.) and loading global configuration data.
In the past this was done using a hard-coded script. From v1.3.0 on, however, Zen Cart® now uses a control array to decide which functions / classes / data files are to be included and initialised.
This allows contribution authors and third party developers to gain access to and extend the initSystem without compromising upgradeability.
Observer class
The Observer Class allows a plugin to listen for for (observe) an event (a notification) and provide additional processing.
This notifier/observer interface also works in the Zen Cart admin panel.
Adding a notifier at specific processing points in the popular (e.g. orders.php
, customer.php
) admin pages, and providing observer code to insert their customization, may help installation and upgrade processes go much more smoothly.
Require login for EZ page
File:
/includes/modules/pages/page/header_php.php
Around line 23:
if ($ezpage_id == 0) zen_redirect(zen_href_link(FILENAME_DEFAULT));
Right below that, insert the following code, substituting '55' with the number of the page to protect:
if ($ezpage_id == 55) {
if (!$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, , 'SSL'));
}
}