douhoulei4706 2015-11-06 10:46
浏览 37
已采纳

Zend框架 - 如何将变量传递给模板?

in ZF2, how can i pass a variable to the following template.phtml?

for example i am loading my template.phtml as following in the home page:

<?=$this->render("layout/forms/template");?>

where template.phtml has following code, but i need to print something inside that template here: <?=$this->????????;?> by passing value from: <?=$this->render("layout/forms/template");?>

<h1 class="free-trial-title">More Information: <?=$this->????????;?></h1>
<section class="free-trial-form">
  <input type="text" name="txtName" id="txtName"  placeholder="Full Name"/><em>*</em><br/>

  <a class="read-more" id="btnContactMoreInfo" nohref>SUBMIT</a>  

</section>

How can i pass the value from home page to that template.phtml please?

  • 写回答

1条回答 默认 最新

  • dqlxtv1452 2015-11-06 11:00
    关注

    If you render the additional view as a partial, you should have no problems.

    <?php echo $this->partial('partial.phtml', array(
        'from' => 'Team Framework',
        'subject' => 'view partials')); ?>
    

    Source: http://framework.zend.com/manual/current/en/modules/zend.view.helpers.partial.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料