0

I want to know the proper way of identifying a template file.
For e.g.
In my basket page (cart.phtml) there is a code like...

echo $this->getChildHtml('shipping');  

I searched for the template for this as follows.....

  1. I checked "checkout.xml" file for the handle "checkout_cart_index". And find where it is written "as='shipping'" and found that code as follows...

    <block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="checkout/cart/shipping.phtml"/>'
    
  2. So I checked the "checkout/cart/shipping.phtml" file and try to modify it. But nothing happend. so I confirmed that it is not the right phtml file I am looking for.

  3. When I enable "Template Path Hints" from admin side , then came to know that it is coming from a different folder and it is due to the extension used. And in its layout file it is written as

    <checkout_cart_index>  
    <reference name="checkout.cart">  
    <block type="webshopapps_productmatrix/checkout_cart_shipping"name="checkout.cart.shipping" as="shipping" template="webshopapps/productmatrix/checkout/shipping.phtml"/>  
    <reference>
    </checkout_cart_index>
    

So My question is ,what is the proper way to know the template files which is used in our page as ChildHtml ?

1

I think you sort of answered your question by yourself : If you are really lost, and can't find which template is called, then the best way is to use the Template Path Hints.

But I agree that it is sometimes a pain to use, as it is breaking the design, make you have to go to the settings, reload the page, etc...

So when I look for which template to modify, I usually start by making a search in my layout files. If your code is like that echo $this->getChildHtml('shipping');, then, you know that you need to find a block called shipping.

You also need to know how the configuration files for layout are loaded. The order of preference will be

Current theme / Current package > Default theme / Current package > Default theme / Default package

And last thing, if a module depends of another module, then it will be loaded after, and therefore will replace its configuration. (Like in your case)

Sometimes it can be a detective work, but most of the time, just by searching for the right name in the different layout folders you will have no more than 3 or 4 files, and you should be able to get the good one.

3
  • Hello. By looking which file I know that a module depends of another module. Jan 11 '16 at 5:33
  • Those declarations are in the etc/modules/ folder, in each module declaration file. You should have a line stating <depends><Module/></depends>. If there is no dependence, then this line will be absent.
    – hellimac
    Jan 11 '16 at 6:11
  • @kishore-patra If this way of doing things correspond to what you are looking for, please consider accepting the answer.
    – hellimac
    Jan 12 '16 at 6:37

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.