Using the model
While exploring CmsController
, we saw that the init()
method contained this portion of code:
if ($id_cms = (int) Tools::getValue('id_cms')) { $this->cms = new CMS($id_cms, $this->context->language->id, $this->context->shop->id); }
This code is important because it selects data from the database for the CMS page with id_cms
equaling the id_cms
GET variable value. It is a good example for us to review:
if ($id_cms = (int) Tools::getValue('id_cms')) { }
This code is storing the value of the id_cms
GET variable retrieved with the help of Tools::getValue('id_cms')
. If the id_cms
GET variable doesn’t exist, it won’t work. Feel free to inspect the /classes/Tools.php
file if you want to know more about the Tools::getValue(key, $default_value =
false)
definition.
The following code stores in the $cms
variable the CMS
object instance extending...