How to override the admin template file in magento? - magento

I need to override the "adminhtml/sales/order/create/items/grid.phtml" file to display some custom text under each item while creating new order from admin. I want this to be done through custom module. Anyone can suggest how to override the admin template files? Any help is really appreciated

I Recommend you that create a new template and add new design in your module with the layout update for the adminhtml section.
For example:
In your config.xml of your custom extension you can update the layout of adminhtml with:
<adminhtml>
<layout>
<updates>
<adminhtml>
<file>yourcustomlayout.xml</file>
</adminhtml>
</updates>
</layout>
</adminhtml>
Ok, then since this layout you can write the next code to add a css for example:
<layout>
<default>
<reference name="head">
<action method="addCss">
<name>aw_all/css/window.css</name>
</action>
</reference>
</default>
</layout>
In your case you need add you custom template for your block
<layout>
<handle>
<reference name="content">
<block type="smspremium/adminhtml_smspremium" name="smspremium">
<action method="setTemplate">
<template>customtemplate.phtml</template>
</action>
</block>
</reference>
</handle>
</layout>
If you want to discart all the block and replace with your block you can made unsetChild
<layout>
<handle>
<reference name="content">
<action method="unsetChild"><name>your.last.block</name></action>
<block type="smspremium/adminhtml_smspremium" name="smspremium">
<action method="setTemplate">
<template>customtemplate.phtml</template>
</action>
</block>
</reference>
</handle>
</layout>
This work same the frontend layout, only with the diference of the directory since you store your files.
For Templates:
app/design/adminhtml/default/default/templates
For layout:
app/design/adminhtml/default/default/layout
Hope help you

Basically, you have to declare a new layout file for your module for adminhtml area, than set a new template path using setTemplate method and reference[name] node.

First of all I'm not believe this is the correct way of overriding adminhtml templates. But I try this approach and it works, So just wanna share.
Add this to your custom Module config.xml
<stores>
<admin>
<design>
<theme>
<default>default</default>
<template>mycustom</template>
</theme>
</design>
</admin>
</stores>
Now You can just override by copying templates from default to mycustom
app\design\adminhtml\default\default\template\sales\order\view\history.phtml app\design\adminhtml\default\mycustom\template\sales\order\view\history.phtml

You can find the detailed instructions for overriding Magento admin files here http://www.techawaken.com/creating-a-new-magento-admin-theme/

Related

Two layouts configuration in config.xml

I am trying to use two layout files, one for taking data from user and saving it into database and other to display content from it.I don't know how to configure config.xml for adding two layout files in magento.
Here is my layout configurations in config.xml
<layout>
<updates>
<helloworld>
<file>displaydata.xml</file>
</helloworld>
<helloworld>
<file>helloworld.xml</file>
</helloworld>
</updates>
</layout>
You can use your single layout file to define multiple handlers.
http://code.tutsplus.com/tutorials/custom-layouts-and-templates-with-magento--cms-21419
In this tutorial, at last it is specified how to use our custom layout for extension.
You can add new handler like follows.
<?xml version="1.0"?>
<layout version="0.1.0">
<mymodule_index_index>
<reference name="content">
<block type="mymodule/mymodule" name="mymodule" template="mymodule/mymodule.phtml" />
</reference>
</mymodule_index_index>
<!-- this is new handler -->
<mymodule_index_test>
<reference name="content">
<block type="mymodule/mymodule" name="mymodule" template="mymodule/test.phtml" />
</reference>
</mymodule_index_test>
</layout>
And in controller you can add relevant action for this new handler

Magento 1.9 - modifying layout

What is the best way of modifying a layout for Magento 1.9? I've been updating layouts using the admin backend but now need to do this programatically. Several articles have mentioned using layout.xml but for some reason, my system isn't picking up the layout updates.
Specifically, this is what I'm trying to modify:
Original layout
<block type="catalog/product_view_options" name="product.info.options" as="product_options" template="catalog/product/view/options.phtml">
<action method="addOptionRenderer">
<type>text</type>
<block>catalog/product_view_options_type_text</block>
<template>catalog/product/view/options/type/text.phtml</template>
</action>
...
</block>
Modified layout
<block type="catalog/product_view_options" name="product.info.options" as="product_options" template="catalog/product/view/options.phtml">
<action method="addOptionRenderer">
<type>text</type>
<block>catalog/product_view_options_type_text</block>
<template>catalog/product/view/options/type/newfile.phtml</template>
</action>
...
</block>
My modified layout is located in:app/design/frontend/default/(company name)/(module name)/layout/layout.xml
layout.xml (just checking to see if it will add the block, "test"):
<layout>
<default>
<block type="core/text_list" name="test"/>
</default>
</layout>
app/code/local/(company name)/(module name)/etc/config.xml:
<config>
<modules>
...
</modules>
<frontend>
<layout>
<updates>
<(module name)>
<file>local.xml</file>
</(module name)>
</updates>
</layout>
</frontend>
</config>
Can somebody point me in the right direction? Thanks!
Here are two things I notice which should be changed:
Your layout update file should have a unique name that won’t conflict with existing modules. In your config.xml you have specified <file>local.xml</file>. The problem with this is, local.xml will already be loaded automatically by Magento. So you should not use that filename for your layout update file if you are trying to add a new one specific to your module, however you may add miscellaneous updates to that file and they will get picked up automatically and applied last to the final merged layout.
Behind the scenes there’s an <updates /> section of the global config that contain nodes with all the file names to load. Once the files listed in the config have been combined, Magento will merge in one last xml file, local.xml.
Your layout update file app/design/frontend/default/(company name)/(module name)/layout/layout.xml does not appear to be in the right location. You should create your new layout update file at: app/design/frontend/base/default/layout/(company name)/(module_name).xml. Then, you need to update your config.xml to point to this file: <file>(company name)/(module name).xml</file>.
Because of the ability to use different themes in Magento and its fallback mechanism, all extension related theme files are placed in “base/default” package for frontend...

How to remove additional tab on product page magento

I want to know How to remove additional tab on magento product page. I have using Ultimo theme on magento 1.7.0.2
I try to search from previous post but still can't remove it.
I have add additional information to a product description and change a name to "ข้อมูลสินค้า"
My point is remove a second tab but still show information on "Product description
This is my product page. http://www.siameyewear.com/ray-ban-rb3025-001-58-aviator-large-metal.html
Thank you.
I'd create local.xml file inside your theme folder app/design/frontend/[your_package]/[your_theme] (if you haven't already)
And insert the following lines there
<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_product_view>
<reference name="product.info.tabs">
<action method="unsetChild">
<child>product_additional_data</child>
</action>
</reference>
</catalog_product_view>
</layout>
After that clear the cache.
If you prefer to edit XML in separate files (which I'm not), find catalog.xml of your theme.
find the following line and comment them (<!-- -->)
<action method="addTab" translate="title" module="catalog"><alias>additional</alias><title>Additional Information</title><block>catalog/product_view_attributes</block><template>catalog/product/view/attributes.phtml</template></action>
Are you create new attribute for product description .remove any one of the product attribute.
you can remove your attribute in your magento admin page .
Catalog->attributes->manage attributes
select your attribute you want to delete.
OR
open your attribute check "Visible on Product View Page on Front-end" change yes to no
I am using my module adminhtml layout xml to add or remove tabs (you could use your theme's local.xml, based on these steps with a bit of tweakking.)
Firstly you will need to declare your layout updates (in your module config.xml) like the following:
<adminhtml>
<layout>
<updates>
<mymodule>
<file>mymodule.xml</file>
</mymodule>
</updates>
</layout>
</adminhtml>
Then in mymodule.xml, add the following (here, I am using the admin order view page handle)
<adminhtml_sales_order_view>
<reference name="sales_order_tabs">
<action method="removeTab">
<name>order_shipments</name>
</action>
<action method="addTabAfter">
<name>order_shipments_mymodule</name>
<block>mymodule/adminhtml_order_shipments</block>
<after>order_creditmemos</after>
</action>
<action method="addTab">
<name>order_receipts</name>
<block>mymoduled/adminhtml_order_recp</block>
</action>
</reference>
</adminhtml_sales_order_view
Hope this helps!! (Don't forget to upvote this solution)

How to load a js file on magento admin dashboard

I am trying to load a js file through XML on the dashboard page of magento admin, but am unable to get it right.
Here is the part of code that I have added in my config file:
<config>
<adminhtml>
<layout>
<updates>
<anattadesign_abandonedcarts>
<file>my_extension.xml</file>
</anattadesign_abandonedcarts>
</updates>
</layout>
</adminhtml>
</config>
And my contents of my_extension.xml which is placed under /app/design/adminhtml/default/default/layout/ is:
<layout>
<default>
<reference name="head">
<action method="addJs"><script>my_extension/adminhack.js</script></action>
<action method="addJs"><script>prototype/prototype.js</script></action>
</reference>
</default>
</layout>
I understand that I am trying to load a js file for the whole admin this way, but I would like to know both, loading on a certain page, and how to find out the name if I want to load it on a certain page and if default is the correct one to make it load on all admin pages.
Using default should load it on all pages, indeed.
To load it on just admin dashboard use the (full 3 element) route with underscores as separators to the page. For the dashboard this is Adminhtml/(controllers)/Dashboard(Controller)/index(Action).
<layout>
<adminhtml_dashboard_index>
<reference name="head">
<action method="addJs"><script>my_extension/adminhack.js</script></action>
<action method="addJs"><script>prototype/prototype.js</script></action>
</reference>
</adminhtml_dashboard_index>
</layout>
N.B. I have not tested this code, but I think it should do it.

How do I override the review tab on OnePage Checkout

I am writing a custom module to change the display of the table on checkout/onepage/onepage.phtml I can see in checkout.xml how it gets declared with
<block type="checkout/onepage_review" name="checkout.onepage.review" as="review" template="checkout/onepage/review.phtml">
<block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
</block>
What I can not figure out is how to set up the /app/design/frontend/{location}/{theme}/layout/{module}.xml file to override the current review.phtml template with the new one. My thought would be to remove the current one and reload with the new one but that doesn't seem to be working.
The first thing i can see is the directory you are using is incorrect.
it should be
app/design/frontend/{location}/{theme}/layout/{module}.xml
instead of
app/layout/frontend/{location}/{theme}/layout/{module}.xml
Also, i'm not sure exactly what you want to do with regards to overriding the review layout table, but the following will replace the review template with your own:
<checkout_onepage_review>
<reference name="root">
<action method="setTemplate"><template>checkout/onepage/your_template.phtml</template></action>
</reference>
</checkout_onepage_review>
Secondly, if you are creating a custom module and want your layout file to be loaded, you have to declare the layout update in your modules config.xml. have you done this?
It would look something similar to this:
<?xml version="1.0"?>
<config>
<modules>
<Your_Company_Your_Module>
<version>1.0.0</version>
</Your_Company_Your_Module>
</modules>
<frontend>
<layout>
<updates>
<yourmodule>
<file>yourmodule.xml</file>
</yourmodule>
</updates>
</layout>
</frontend>
</config>
Finaly, depending on what you are trying to achieve, you may not require a module just to override the checkout review table.
If the sole purpose of the module is simple to override the checkout layout, then it would probably be sufficient to just override the layout by using one of the following methods:
Use local.xml
Create a local.xml file in your themes layout directory:
/app/design/frontend/{location}/{theme}/layout/{module}.xml
and use this for all core layout overrides. There are lots of benefits to this.
Copy the base checkout.xml layout file to your theme
Copy app/design/frontend/base/default/layout/checkout.xml
To app/design/frontend/{location}/{theme}/layout/checkout.xml

Resources