I am currently creating a button for a single order in Magento(next to invoice, ship, reorder etc.). I would like the button to be inside a template to allow for php variables from that order and external js files to be added.

I am currently trying to override the sales order view page and add code from their, this seems to be the best/simplest way. It's reading the new template, but everything else is getting messed up. How do i fix this?




class MyApp_OrderButton_Block_Sales_Order_View_Info extends Mage_Adminhtml_Block_Sales_Order_View_Info
    protected function _construct()

Potential template, php, and js:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
function connect() {
    var allsongs = '<?php echo $x ?>';
    lib = {
        songs: allsongs,
        albums: 20

This is read by magento, but it messes up the whole page: enter image description here

  • Could you add the JS function and explain what you are trying to accomplish? Jul 15, 2015 at 23:19
  • @R.S The javascript function has added scripts from www.example.com/api/myapp/myjs.js and a popup window from example.com comes up. I would like the clicking of the button to trigger this function, but have the button, php, and js all connected, so it must be in a template.
    – qwerty123
    Jul 15, 2015 at 23:26
  • @R.S code added
    – qwerty123
    Jul 15, 2015 at 23:49
  • What type is $x? Unless it is a int or object then it should be var allsongs = '<?php echo $x ?>' (you are missing the echo) Also what error are you getting? Jul 16, 2015 at 0:02
  • @R.S question updated
    – qwerty123
    Jul 16, 2015 at 18:02

2 Answers 2


I believe your first question is you are not able to override info.phtml file. If that's the case then

Change your layout this way:

<?xml version="1.0"?>
        <reference name="order_tab_info">
            <action method="setTemplate">


Remember if you using layout file to override template then you don't need to rewrite block in config.xml, unless you are also overriding some function or adding new function to it.


Magento layout setTemplate is so powerful that it will handle the work for you.


Instead of rewriting the Info block just to make changes to the template file, you may want to consider creating an admin theme. See Magento - Override adminhtml template file

Assuming that your rewrite is working correctly (by view page source or use magento template hint)


var allsongs = <?php $x ?>;


var allsongs = <?php echo $x ?>;
var allsongs = '<?php echo $x ?>';

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.