Properly override a admin template file in Magento - magento

I want to properly override this admin template file app/design/adminhtml/default/default/template/sales/order/create/form/address.phtml
From what I have found, the proper way is to create a layout file in a new module, set template path inside my module directory and reference that template file using reference node. But I have no clue how to do that.
I don't understand how the layout is controlled using xml as of now. Can someone show how to actually do that?

You should really create your own module, which you can then create a new template.
If you want to force is you need setTemplate() which takes your phtml path as a param. $this->getLayout()->createBlock('my_module/blockname')->setTemplate('my_module/template.phtml');
Bear in mind that the two slash notations here are different.
createBlock() is for a block, so will be in /app/code/<codePool>/My/Module/Blocks/<blockname.php>
setTemplate() is for the template, so will be in /app/design/<area>/default/default/template/template.phtml
Your <area> will be /adminhtml as you're in the admin backend.
In order to get the template working you'll need to create a new module and extend the adminhtml block file which uses this template. You'll have to find the block from the layout.xml and then you can extend the Block and specify a new template.
That's how I'd go about it, but I'm also really finding it hard to override things in the Adminhtml module.

Related

Create admin front with a simple form via a module [Magento]

I am pretty new to Magento and am trying to understand how to create admin (backend) page. I have figured how to create/define the controller and action (along with editing the config.xml).
But now the next problem at hand is to display a simple form in that page. I understand that, I have an option to create blocks and mention the blocks in a layout.xml. But from what I figure is that layout.xml needs to be present in the theme folder. Which I can't do as my magento extension will be installed and I have no access to the user's system.
So the doubt is. How to display a simple from in a backend (admin) page
without having to make any changes to the theme's layout ?
For the admin panel module you don't need to mention the block in the layout.xml of your theme, you only need it to be defined in config.xml file in your "app/code/local///etc/" and a layout file is created in "app/design/adminhtml/default/default/".inside the Block create a folder named "Adminhtml" inside it your can create your form.
Refer this
http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_create_an_admin_form_module

Different .phtml to diffrent type of product

I am trying to make module that switches diffrent .phtml of productview depend on attributeset name. I dont know witch file is responsible for rendering productview.
It is usually Magento Block that render template. In your case productivew is rendered by
Mage_Catalog_Block_Product_View.
You can easily figure this out by enabling template_hints and template_hints_blocks. To enable these to option follow steps below:
Go go Admin
System > Configuration
In left column, Select Developer under Advance.
Change Current Configuration Scope to website level (template_hints and template_hints_blocks is applicable at website level only)
Make yes to Template Path Hints and Add Block Names to Hints under Debug group.
you can rewrite this class:
Mage_Catalog_Block_Product_View
and then you can add your own logic to it to switch to another template, not the standard
catalog/product/view.phtml

PyroCMS Custom Module Layout

I created a custom module called Drawings. I wanted to give it its own theme layout on the frontend, so I followed the advice I found HERE - I put a layout file titled Drawings.html in my theme.
This had the correct effect on the frontend, but caused other problems and questions that I've been struggling to sort out:
The backend admin section for my module now uses the Drawings.html layout, which breaks its functionality completely. How can I set a specific layout for my module front end, but keep the standard admin backend layout (same backend implementation as in the sample module tutorial)?
I read the following in the Template Library: "When using Public_Controller and Admin_Controller, the layout is already set." Perhaps the solution involves using the set_layout function in these controllers somehow? All my attempts failed so far though.
I feel I am doing something incorrectly because now my module is not modular. For example, after creating the Drawings.html layout file in the theme, a statement like {{ theme:css file="drawings.css"}} in that layout file searches for those resources in my theme. So I have to put those JS and CSS resources in my theme, instead of in my module's CSS and JS folders. How do I keep and access my resources in the module's JS and CSS folders?
I don't know how this is supposed to work.
When you are using front end controller use a layout there using philsturgeon template library like this
function index(){
$this->template->set_layout('drawing')
->build('yourview');
}
This way you can load a custom layout for your application.

Multistore, template code from code/local/

I'm prepare a multistore on magento.
I have a three template, and I was change a few file from code/core and replace in code/local, but only one template take a changing code from code/local
a rest template should take file from code/core/
Now every template take files from code/local/
How can I'm set app to resolve a problem
thx for help
You should NOT overwrite core files in local. Better try to develop your own module which rewrites the core functionality. In this module you can integrate a configuration, so it's only used for one store view, and not for all.

Best way to link Category to customized Modul

So far i have found two ways of liking a category to a customized module. By Category i mean created in Admin->Catalog->Manage Categories->created new category. By Customized module i mean module created in code(app/code/local)
way to link
Till today I used Admin->Catalog->Url Rewrite Manager to direct some category(blog) to some customized module(blog/index/index). So, in Url Rewrite manager I created rewrite entry that had Request-Path hold Category Url-key(blog-index.phtml) and Target-Path hold my costumized module path (blog/index/index). It stop redirecting today by having automatically putting different target path (catalog/category/view/s/blog-index/id/)...i am not sure why
2.way to link
In category layout xml file I put handle
This does the work but it requires to mess with category module that i prefer not to do. It also has link(catalog/category/view/s/blog-index/id/) that does not favor search engines
Is there better way to link category to my costumized module?
The layout XML can go in your module's layout XML file (layout/blog.xml for example) if you'd prefer, the file that layout XML resides in has little importance (you'll need a <layout> section in your config.xml if you don't already have one)

Resources