Home >Backend Development >PHP Tutorial >How can thinkPHP render two V-layer template views in the same function?
I want to use different templates, one set is called red and the other is called read..
<code>public function addData() { $this->theme( 'red' )->display( 'form' ); $this->theme( 'read' )->display( 'addData' ); //这个使用了不同的模版文件, //但是他把不识别,还是从上一句的 red 模版找 addData.html 文件 ... }</code>
I want to use different templates, one set is called red and the other is called read..
<code>public function addData() { $this->theme( 'red' )->display( 'form' ); $this->theme( 'read' )->display( 'addData' ); //这个使用了不同的模版文件, //但是他把不识别,还是从上一句的 red 模版找 addData.html 文件 ... }</code>
This has never been used before. In fact, it would be better if the content in your display is directly spliced. $this->display(folder+file), if you render it like this, if your template is the same but the folder is different, it should solve the problem.
Use ajax asynchronous call to assemble the two templates into one
<code>public function addData() { $result = []; $result['red']= $this->fetch('Member:red'); $result['read']= $this->fetch('Member:read'); return $this->ajaxReturn($result); }</code>