Here is the application scenario of my own project
The requirement is to use the layer component of the layui framework to achieve the pop-up layer effect, which is undoubtedly easy to do with the original PHP, but it will be very troublesome if it is applied to the crossphp framework process
Here are the general steps:
1. Apply the layer component of layui in a template file to realize the pop-up box
index.tpl.php
2. It can be easily seen from the path defined by ourselves that this `path should be the kk method of the settle controller in the root directory of the domain name
Then, because the template file is used, the view controller must be displayed in the controller
Controller definition settle.php
display to views\SettleView.php\kk method
class SettleView extends AdminView
{
/**
* @param array $data
*/
function index($data = array())
{
$this->renderTpl("settle/index", $data);
}
function kk($data=array())
{
$this->set([
'layer'=>'kk'
]);
$this->renderTpl('settle/kk',$data);
}
}
3. Then use the renderTpl method to load the template file
Here, because we use templates, we need to consider the default layout file. Here, we simply do not use the default layout file, but define a layout file ourselves. This layout file should be placed in the default templete path set in init.php.
That is, the module name\templete\kk.layer.php
4. Then, we can write the code of the template file kk.tpl.php
In this way, we have completed the process of transferring the code from native php to crossphp