4

I have following javascript files included in layout:

$this->InlineScript()->appendFile($this->baseUrl('resource/js/jquery.js'));
$this->InlineScript()->appendFile($this->baseUrl('resource/js/main/login.js'));
$this->InlineScript()->offsetSetFile(3,$this->baseUrl('resource/js/core.js'));

I have following script in view file:

<?php $this->InlineScript()->captureStart() ?>
    alert('This is Inline Script in View');
<?php $this->InlineScript()->captureEnd() ?>

Right now, my script in view file, is inserting before all javascript files.

How can I insert my inline script before 'core.js' and after 'login.js' file

1
  • Your second code snippet looks like a placeholder. Right now I am a little stumped about your appendFile methods to the placeholder. I wasn't aware you can do that, but then have you tried prependFile()? Commented Jul 4, 2011 at 14:01

1 Answer 1

3

in layout you can used appendFile() and prependFile() combinations,if you will have some place for file...

and...

in "layout.phtml":

<?php echo $this->inlineScript(); ?>

in "test.phtml":

<?php $this->inlineScript()->captureStart() ?>
alert('This is Inline Script in View');
<?php $this->inlineScript()->captureEnd() ?>

result:

<html>
<head>
<script type="text/javascript">
//<!--
alert('This is Inline Script in View');
//-->
</script>  
</head>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.