我在default.ctp布局中设计了一个页脚
<div class="container-fluid footer-wrapper hidden-xs hidden-sm " style="margin-top:50px;">
<div class = "row" style="padding-top:50px;">
<div class="col-md-4">
some text
</div></div></div>
等等
现在我有另一个文件purchase.ctp,所以只写
<?php echo $this->Element('footer'); ?>
,它会实现从default.ctp到purchases.ctp的页脚,还是我必须对default.ctp页脚进行一些更改或在那里写一些代码?
我是CakePHP的新手,所以听起来像是一个愚蠢的问题。
答案 0 :(得分:1)
创建这样的页脚时,它不应该位于default.ctp
布局中。
要在多个布局上重复使用页脚,请创建一个新元素:
app/View/Elements/footer.ctp
文件(使用CakePHP 2.x时)src/Template/Element/footer.ctp
文件(使用CakePHP 3.x时)。然后在您的default.ctp
布局和purchases.ctp
布局中,只需嵌入它:
echo $this->element('footer');
这样,无论何时编辑页脚中的任何内容,它都会在使用它的所有布局中进行编辑。