Consider following two files:
// view/index.phtml
echo \Phalcon\Tag::javascriptInclude("javascript/jquery.js");
// view/about/about.phtml
echo \Phalcon\Tag::javascriptInclude("javascript/x.js");
About will generated like:
<script src="javascript/x.js">
<script src="javascript/jquery.js">
But x.js file is depended on jquery.js so it should placed before it.
Suppose you have the following structure:
app/views/index.phtml
app/views/about/index.phtml
You can define the following in the app/views/index.phtml at the top
<?php echo \Phalcon\Tag::javascriptInclude("javascript/jQuery.js"); ?>
<?php echo \Phalcon\Tag::javascriptInclude("javascript/myother.js"); ?>
and then in the app/views/about/index.phtml
<?php echo \Phalcon\Tag::javascriptInclude("javascript/x.js"); ?>
That would get the jQuery.js and myother.js scripts to load before the x.js does, since the x.js will come in the master view with the
<?php echo $this->getContent() ?>
Alternatively, you could set this in your master view:
<?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"); } ?>
and in your About controller
$this->view->setVar('is_about', TRUE);
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With