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
Release: 2016-09-03 00:14:12
Original
1189 people have browsed it

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template