Home >Backend Development >PHP Tutorial >How can thinkPHP render two V-layer template views in the same function?

How can thinkPHP render two V-layer template views in the same function?

WBOY
WBOYOriginal
2016-09-03 00:14:121208browse

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>

Reply content:

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>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn