-
Book Overview & Buying
-
Table Of Contents
PrestaShop Module Development
By :
The Context objectis a directory containing a list of objects. It is available in controllers and modules, and you can access it this way:
$this->context;
If you are not in a controller or a module, you can retrieve it by using the getContext method. The Context class uses a singleton and this function will return the instance of the Context object:
$context = Context::getContext();
In a few words, if you don't know what a singleton is, it's a system that restricts the instantiation of a class to one object. Although this is not mandatory, it's a good idea for you to read some articles, such as the Wikipedia article about it at http://en.wikipedia.org/wiki/Singleton_pattern .
Here is the list of objects available in the Context class:
cart: This object contains the Cart object of the customer in the front office. This object is not available in the back office:
$this->context->cart;
customer: This object is filled with the Customer object in the front...
Change the font size
Change margin width
Change background colour