Home  >  Q&A  >  body text

php - tp template inheritance problem

Use tp3.3 to create a background management system. I tried using tp's template inheritance and encountered a problem.
Example:
Add administrator method:

public function addC(){
    echo "1234";
    $this->display();
}

$this->dispaly();Displayed template page:
<extend name="./Application/Rbac/View/base.html" />
<block name=" content">
Form...
</block>

Problems encountered:
echo "1234"; cannot be displayed. I also have no way to var_dump($_POST) the data submitted by the form. This should be related to the mechanism of tp template inheritance. How should I modify the code? Thank you.

给我你的怀抱给我你的怀抱2673 days ago546

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-05-27 17:45:33

    public function addC(){

    $t =  "1234";
    $this->assign('t',$t);
    $this->display();

    }

    Template page
    <!DOCTYPE html>
    <html lang="en">
    <head>

    <meta charset="UTF-8">
    <title>Title</title>

    </head>
    <body>
    <p>{$t}</p> //1234 will be displayed here
    </body>
    </html>
    As for the form submission For data, ajax is usually used, and a new saveC method is created in the background to receive form data and complete the warehousing operation

    reply
    0
  • Cancelreply