0

im kinda new to magento and I struggle with one thing now. I have modified app\design\frontend\base\default\template\tax\checkout\subtotal.phtml for a simple functionality. It's working ok, I basically only call one function in my custom helper of my module. However I need to keep magento updated, so I added this phtml to my template file in base theme where I have other files like JS and CSS for my custom blocks.

Problem is, this tax\checkout\subtotal.phtml is displayed because \design\frontend\base\default\template\checkout\cart\totals.phtmlcalls $this->renderTotals(); so Mage_Checkout_Block_Cart_Totals handles this. I dont want to override core function to force my phtml file (I also think this wouldnt be good idead), I would like to keep it as simple as possible. I work in RWD theme, but I want to display this functionality throughout all themes so I have my templates and layout in base theme folder. Also I dont want to solve this by changes in backend, I want to do it purely programmatically.

Thx in advance :)

0
  1. Local_Module_Custom_Layout_File.xml: Insert a block where you want your custom template located (like below for yourTemplate.phtml

    <checkout_cart_index translate="label">
        <reference name="content">
            <block type="checkout/cart" name="checkout.cart">
                <block type="core/template" name="custom_name_here" after="checkout.cart.totals" template="path/to/yourTemplate.phtml"/>
            </block>
        </reference>
    </checkout_cart_index>
    
  2. Put your template file in design/frontend/path/to/yourTemplate.phtml

  3. In your template call your helper function (you can also create a custom block class and put the function there)

    <?php
    /** OPTIONAL
    * Template Title
    *
    * @see Where_You_Can_Add_Your_Block
    */
    ?>
    
    <div>
         <?php echo Mage::helper("YourModule")->function() ?>
    </div>
    

Benefit: Leaves the core alone and all changes are made in your local module so if you disable the module in the future you do not need to go back and edit template files

1

First, it's forbidden to change the core files and base files, please copy app\design\frontend\base\default\template\tax\checkout\subtotal.phtml to app\design\frontend\{current package}\{current theme}\template\tax\checkout\subtotal.phtml, do your update in this one and put the base\default/... file as it was.

Secondly, copy like the same way, the file that you want to update or override from the base/default to your current theme.

Finally check in admin panel if you have well set your current theme in : system->configuration->general->design->themes put your current theme in : default, layout, templates, skin, with this config Magento takes First the files from your current theme then the default one then the base. What is called : Theme fallback system

  • Thingy is that modification I have described is part of module, that overrides some basic Magento functionalities. What I am trying to achieve is that I want to add custom string into checkout before price and it should not be part of a theme. I have tried different approaches, but either it is problematic or not possible to do without changing phtml file. So I tried first modifying core phtml to see where I can do changes, then to move this into my module and revert changes in core phtml. There is no other intention behind modifying core files. – JohnyProkie Sep 21 '17 at 11:14

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.