Magento: adding a block to 'admin/sales_order_create/index' page - magento

I have been trying to add a custom block to 'admin/sales_order_create/index' page with limited success.
The custom block does not show up after i choose a customer or clicking "create new customer". But when I refresh the page after the order loads, my custom block shows up.
I added the custom block with the following XML:
<adminhtml_sales_order_create_index>
<reference name="data">
<block type="fflshipment/adminhtml_orderlocator" name="order_ffl_locator" template="fflshipment/create_order_address.phtml"/>
</reference>
</adminhtml_sales_order_create_index>
Am I missing something?

Look again at the sales.xml file, as well as an adminhtml_sales_order_create_index handle there is an adminhtml_sales_order_create_load_block_data handle further down, this is sometimes loaded by AJAX. Your layout needs to modify both handles equally.

Related

Edit the catalog page for specific category

I am using Magento 1.8.1 and I am working on SEO. I need to put micro-data (schema code) for some category on that page only. I don't understand how to put the data for specific page because if I put any data in template page, it will update on all categories.
For example: I need to put data only for this page.
As I understand it, you want to add some code to only appear on a specific category view. You can add Javascript to the description field in the General Information tab of the category:
You can also add a template to before_body_end block of the page:
You can add additional layout directives here. This layout update:
<reference name="before_body_end">
<block type="core/template" name="seocode" template="seocode/seocode.phtml" />
</reference>
means render out your custom block (seocode) and template file (seocode.phtml) in the before_body_end block. The before_body_end block can be found in the page templates; i.e. page/1column.phtml or page/2columns-left.phtml.

Hide category menu using local.xml

How to hide category/menu bar on selected pages like login & registration using local.xml ?
I'm using magento 1.7.0.2
You need to remove block named 'catalog.topnav' for login and registration page handlers. The page handler similar to page URL, but all slashes replaced with '_'. For the login page it will be *customer_account_login* and for the registration page - *customer_account_create*. You can use
<remove name="[blockname]">
or
<action method="unsetChild"><block>[blockname]</block></action>
instructions, first allow you to remove block globally and the second one remove it from certain block.
The Layout update for default magento theme will looks like:
<?xml version="1.0"?>
<layout version="0.1.0">
<customer_account_login>
<remove name="catalog.topnav" />
</customer_account_login>
<customer_account_create>
<remove name="catalog.topnav" />
</customer_account_create>
</layout>
There is some explanation about Magento layouts which can be useful - http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-4-magento-layouts-blocks-and-templates
Remove nodes will be processed after all layout handles are merged, and are a good way to remove a block regardless of which layout handle loaded the block; you just want to get rid of it entirely for some handles! It also removes recursively, so all you need to specify is the layout handle.
On the other hand, you may only want to remove a block from a reference in a specific layout handle, in which case you should use unsetChild. It is often used to remove a block from a reference, but then re-insert the same block with a different position. This would not have been possible with remove.

How to remove 'add to cart' button from one cms page only?

I have created a web store with custom CMS page which has custom layout too. This page will show all the products of the store.
On that CMS page all the product is displaying but
I want to remove 'add to cart' button, 'add to wishlist' link and 'add to compare' link from products
I want to remove these links from that specific CMS page only.
I tried
<remove name="" />
in Layout Update XML of that CMS page but I can't get specific names to remove and while searching I tried every possible name but no success.
Any suggestions?
If you have used a custom layout and you are displaying all products on that page then you must have used block type to display all products in content of that page.
Something like
{{block type="catalog/product_list_random" name="product" template="catalog/product/list.phtml"}}
Simply make a new file and save it on same loction where list.phtml is saved (obviously with different name say new.phtml
Put that new.phtml instead of list.phtml
And delete whatever you don't want to display on that page from new.phtml
You only can remove whole blocks with layout updates like that, but those links and buttons are not separate blocks but get rendered within the Mage_Catalog_Block_Product_List block. You will have to replace the template of this block with your own:
copy /app/design/frontend/base/default/template/catalog/product/list.phtml to /app/design/frontend/YOUR/THEME/template/WHATEVER/catalog/product/list.phtml (use your theme directory and a directory name under template that refers to your CMS page)
edit this copy and remove the links and buttons
in the layout update handle for your CMS page, add:
XML:
<reference name="product_list">
<action method="setTemplate" template="WHATEVER/catalog/product/list.phtml" />
</reference>
(assuming that the product list block is called product_list)
Then, depending on what you want to remove, you can put between the "default" tags the following lines:
<remove name="cart_sidebar" /> "
<remove name="catalog.compare.sidebar" /> "
http://www.hostknox.com/tutorials/magento/remove-default-blocks/manual-removal

rearrange product blocks

I have 3 questions that my normal Googling efforts haven't answered. I'm a in-house front end web developer that has been trying to learn Magento for the past two weeks. I'm also new to posting on Stack Overflow, so let me know if these would be better posted as separate questions or something.
1. Layouts - Making it so every single page uses the same layout
So most of my pages are using my 2columns-left layout, but not all of them. I have some set in my local.xml, and some I just hard coded in the .phtml pages directly. I would have thought the following code would make ALL pages use the same layout:
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
<action method="setIsHandle">
<applied>1</applied>
</action>
</reference>
There are a lot of pages I don't normally see when I work on the site that are stuck with the default Magento layouts, like the /cookies-enabled page, or the review pages. What's the best practice for unifying all pages if you want the same layout on the entire site, rather than having a block like this in local.xml for every single page?
2. Contact Us Form - Clicking the submit button doesn't work
I am editing the contact us page under CMS>Pages, and I think I am possibly missing the file that my form action is pointing to. The form shows up, but it doesn't submit.
Here is what I have on our Contact Us CMS page:
{{block type='core/template' name='contactForm' form_action="/contacts/index/post/" template='contacts/form.phtml'}}
Here's the error I get after clicking the submit button:
Not Found
The requested URL /contacts/index/post/ was not found on this server.
I've gone through the configuration settings and I think those are right, but maybe there is something else I have to do there.
3. Product Reviews - Getting an "Overall" rating to display
I have the review div that utilizes form.phtml showing up on my product pages after you login and add a review, but the ratings aren't being shown. I am apparently not satisfying the conditions of an if statement that controls if the ratings should be displayed. Below is the if statement that it is getting caught on I believe:
<?php if( $this->getRatings() && $this->getRatings()->getSize()): ?>
I'm not sure how to satisfy these conditions.
4. Rearranging Blocks - Using local.xml to rearrange where blocks are going
Before I start developing bad habits, I want to make sure I'm using best practices from the get go. I've typically just gone into the template files and manually move where stuff was appearing in the phtml, but I've heard it's best to make those changes in the XML. One particular issue I can't seem to figure out is a seemingly simple one: How do I make the "Proceed to Checkout" button move to the bottom of the cart?
I'm trying to unset it then re-set it after the other blocks. I haven't even been able to get the unsetChild part to work. Here is my code from local.xml:
<reference name="content">
<action method="unsetChild">
<name>checkout.cart.top_methods</name>
</action>
</reference>
I think the reason this isn't working is because in checkout.xml it's the child of a child. Here's the general flow of the checkout.xml:
<checkout_cart_index>
<reference name="content">
<block name="checkout.cart">
**<block name="checkout.cart.top_methods">**
Any ideas? Thanks so much, and sorry about the length of this post!
1°) Edit all your layout xml to change the layout of the root reference to 2columns-leftf.phtml template
You can also go through an observer. Observe the controller_action_layout_generate_blocks_after event and in your method do :
public function myEventHandling($event) {
$event->getAction()->getLayout()->getBlock('root')->setTemplate('page/2columns-left.phtml');
}
2°) module Contacts controller index action postAction() so it should be /contacts/index/post/ so it should work. Except if you made your CMS page replacing /contacts/ normal behaviour (module contacts controller index action indexAction() ) it will search under your cms page instead of in the contacts module. If your CMS page have contacts as url, try changing it.
3°) Could you be more precise ? I don't really understand what you need. The form or the existing ratings are not showing up ?
4°) UnsetChild or remove instruction are global, you have to set it with a different name after a replace. But you can edit your layout file in your template directory (not the ones on the base/default/layout directory) to move the block in the proper location, and in the phtml file, try to move the
echo $this->getChildHtml('myblock')
in the proper location.

Set Magento block template in layout xml

Having trouble setting a block template in Magento's layout xml. I'm attempting to set the template of a child block, not the entire page layout (almost all docs out there explain how to set template of the layout).
Background: I'm updating a layout handle in my custom action, using the <update /> tag in my module's layout xml.
Essentially, I want to reuse the layout and blocks of the built in product view action, but provide custom templates for a few blocks. (Not just overrides, these need to be brand new templates that are only triggered on my custom action and are themselves overrideable).
My layout html:
<?xml version="1.0"?>
<layout version="0.1.0">
<mymodule_product_index>
<update handle="catalog_product_view" />
<reference name="content">
<block type="catalog/product_view"
name="product.info" output="toHtml" template="mymodule/product.phtml" />
</reference>
<reference name="product.info.bundle">
<action method="setTemplate"><template>mymodule/customtemplate.phtml</template></action>
</reference>
</mymodule_product_index>
</layout>
The setTemplate on product.info.bundle never works; it doesn't seem to affect layout at all. I've tried wrapping the <reference> in other <reference> nodes from parent blocks with no effect. Is it possible to replace block templates in this way? I feel that my problem stems from the fact I'm using an <update />.
By the way, I know my layout xml is being loaded and there are no errors, the rest of the file is working fine, caching is disabled, have cleared cache anyway, etc.
Your approach is almost correct.
Two things:
1. Set a new template instead of instantiating a new block
Instead of just assigning a different template to the product.info block, you are creating a new instance with the same name, replacing the original instance, and then the new template is set on that. Instead use this:
<mymodule_product_index>
<update handle="catalog_product_view" />
<reference name="product.info">
<action method="setTemplate">
<template>mymodule/product.phtml</template>
</action>
</reference>
</mymodule_product_index>
That should take care of the product view template in a clean way.
2. Handle processing order
If you look at where the view block product.info.bundle for the bundled products is declared, you will see it happens in the bundle.xml file, in a layout update handle called <PRODUCT_TYPE_bundle>.
Your code is referencing the block from the <[route]_[controller]_[action]> layout handle, i.e. <mymodule_product_index>.
The thing to be aware of here is the processing order of layout handles.
Roughly it is:
<default>
<[route]_[controller]_[action]>
<custom_handles>
The <PRODUCT_TYPE_bundle> handle belongs to the third type of layout handles, which means it is processed after the <mymodule_product_index> handle.
In essence, you are referencing the block product.info.bundle before it has been declared.
To fix this you will need to use the <PRODUCT_TYPE_bundle> handle as well. Of course this will effect every bundled product display. Using layout XML only there is no clean way around that.
Here are a few suggestions how to solve that problem.
You could create a separate route in your module to show the bundled products, and then include the <PRODUCT_TYPE_bundle> handle using an update directive for that page, too.
In your custom action controller, you could add another layout update handle that is processed after <PRODUCT_TYPE_bundle>.
You could use an event observer to set the template on the product.info.bundle block if it is instantiated. One possibility would be the event controller_action_layout_generate_blocks_after.
You get the idea, there are many ways to work around this, but they require PHP.

Resources