0

How to add a custom template just after body tag in adminhtml in magento?

All working fine if I am trying to add custom template in head but failing if I am doing the same to include custom template in body of adminhtml page.

Here is my code for adminhtml layout file:

<default>
  <reference name="after_body_start">
    <block type="adminhtml/template" template="gtm/after_body_start.phtml" name="after_body_start_script" as="after_body_start_script"/>
  </reference>
</default>

Here is my code for the file present at app/design/adminhtml/default/default/template/gtm/after_body_tag.phtml

<?php
  Mage::log('control coming here', null, 'custom_log_file.log');
?>

If the control logs in my custom log file, It will work for the code I will write in it but I cannot see the log file updating.
It seems that either I am using wrong reference for adminhtml to include a custom template after body start or I am missing to include the block to be included somewhere!
Please guide me to get this done!

0

There is no any reference like after_body_start for admin.

Instead of this you can use before_body_end OR if you want this in top of the page then you can use reference name notifications and the code must be like :

<default>
   <reference name="before_body_end">
       <block type="adminhtml/template" template="gtm/after_body_start.phtml" name="after_body_start_script" as="after_body_start_script"/>
   </reference>
</default>
|improve this answer|||||
  • Thanks Ashish for the help. I do also thought of to move like that if no solution for after_body_start in adminhtml. Is there anything wrong if I quote my code directly just after the <body> tag in the file app/design/adminhtml/default/default/template/page.phtml so as to get my codes just body starts? – Anurag Khandelwal Mar 1 '17 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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