I have beed doing this for quite some time. So i thought lets write it down on the blog as well, so that it is more clear for any one starting with magento. Here is the thing in magento once the control reaches the xml, it finds the corresponding template files to render. So suppose you are on the sales order view page in the admin. So the corresponding xml is lets say sales.xml. Now there will be a block written like this.
<block type=”adminhtml/template” name=”gift_options” template=”sales/order/giftoptions.phtml”>
Now i will explain what each element means here.
First “adminhtml/template” this means that the related block which will call this xml is adminhtml/template, so go to the app/code/core/Mage/Adminhtml/Block/Template.php. The file Template.php is what the block refers to for the functions in the template file “giftoptions.phtml”. Please note that i have highlighted the elements in bold in the path which are used to trace the code.