假设您有以下结构:
app/views/index.phtml
app/views/about/index.phtml
app/views/index.phtml
您可以在顶部定义以下内容
<?php echo \Phalcon\Tag::javascriptInclude("javascript/jQuery.js"); ?>
<?php echo \Phalcon\Tag::javascriptInclude("javascript/myother.js"); ?>
然后在app/views/about/index.phtml
<?php echo \Phalcon\Tag::javascriptInclude("javascript/x.js"); ?>
这将使jQuery.js
和myother.js
脚本在执行之前加载x.js
,因为x.js
将在主视图中使用
<?php echo $this->getContent() ?>
或者,您可以在主视图中进行设置:
<?php echo \Phalcon\Tag::javascriptInclude("javascript/jQuery.js"); ?>
<?php echo \Phalcon\Tag::javascriptInclude("javascript/myother.js"); ?>
<?php if ($is_about) { echo \Phalcon\Tag::javascriptInclude("javascript/myother.js"); } ?>
在你的 About 控制器中
$this->view->setVar('is_about', TRUE);
高温高压