I have been wondering about the issue, that is, like csdn, users can modify their own homepage style, and the modification is permanent. Many places have invited people to hand over the view style to the user. This is also the future. The development trend, like QQ space decoration, and even the backend of some website building programs are like this, so it is very important to understand this principle.
First of all, this is obviously impossible to achieve through the front end, because the things in the front end are ultimately placed in the memory when they reach the user. The memory is volatile, so it should be placed in the background. Similarly, we cannot To directly modify the background files, which is very costly, then we need to put them into the database. The data in the database is stored in the hard disk and is not easy to lose. Moreover, it is also easy to operate through the background files. In this case, the idea is .
In the background visual management interface, various styles of buttons, forms, etc. are stored, including specifically modified pages. In the database, the style data of the foreground view is stored. There is a missing connection in the middle, but smarty is perfect. It solves this problem and separates the data. Modification means modifying the database data, and extraction means extracting the database style. This is the core principle.
Here is a sample code of mine for reference only:
<!--?php namespace Home\Controller; use Think\Controller; class TestController extends Controller { public function test1(){ $info=D("style"); $temp=$info--->select(); $info->id='2'; $info->value=$_POST[value]; $info->save(); $bg=$temp[1]['value']; $size=$temp[4]['value']; echo $bg; echo " "; echo $size; $this->assign(bg,$bg); $this->assign(size,$size); $this->display(); } }