I have found lot information about Magento view generation system and this info looks clear but for some reason I have situation where magento patters not works for me. So my company bought module for checkout page and after some time they decided customize it(add some functionality). If we look to magento standarts we see that we never change source code cuz we have lot mechanism for extend it what actually we tried and found some problem. Have I have peace of layout xml which I would like append my custom block:
<block type="ecommerceteam_echeckout/onepage_billing" name="checkout.onepage.address.billing" as="billing_address" template="ecommerceteam/echeckout/billing.phtml">
<block type="ecommerceteam_echeckout/onepage_billing" name="checkout.onepage.address.billing.form" as="address" template="ecommerceteam/echeckout/billing/address.phtml" />
</block>
And inside billing_address block after address block I would like append my block by follows code:
<layout>
<checkout_cart_index>
<reference name="checkout.onepage">
<block type="kukimi_deliverydate/delivery_date" name="delivery_date" after="address" template="kukimi/deliverydate/delivery/date.phtml" />
</reference>
</checkout_cart_index></layout>
And this is doesn't works but if I change reference to the content it will work what reason for this? how I can manage situations like this?
Related
I'm using a Magento template called Bootstrapped (http://bootstrapped.magenthon.com), and am editing this template to fit our needs.
Since our website's navigation is based on (sub-)categories, we use a roadmap to help guide the user through the system.
Therefore, we have edited the main category of our products with the following custom XML:
<!-- Remove Breadcrumbs -->
<reference name="head"><remove name="breadcrumbs" /></reference>
<!-- Set Roadmap template -->
<reference name="content"><reference name="category.products">
<block type="catalog/navigation" name="roadmap" template="alphabase/catalog/roadmap.phtml">
<action method="setData"><name>roadmap_type</name><value>onderdelen</value></action>
<action method="setData"><name>maxlevels</name><value>6</value></action>
</block>
<action method="setTemplate"><template>catalog/category/view.roadmap.phtml</template></action>
<action method="setData"><name>roadmap_type</name><value>onderdelen</value></action>
<action method="setData"><name>per_row</name><value>4</value></action>
<reference name="products.list">
<action method="setData"><name>roadmap_type</name><value>onderdelen</value></action>
</reference>
</reference></reference>
Now when I apply this update, the website's meta title does not show any of the 'breadcrumbs' that the user has followed so far, it only shows the shop's name.
However, when I remove the custom XML, the meta title neatly displays the 'breadcrumbs' in the title, followed by the suffix we have set through the admin panel.
I have compared the original file in /app/design/frontend/package/default/template/catalog/category/view.phtml with the file I am using, but I just can't seem to figure it out.
I would say it has something to do with the Bootstrapped theme I'm using, but then why would it work when I remove this simple custom XML?
Also, the title does change when I set a meta title in the category settings, and it adds the suffix, but it does not show the 'path'. The website also displays my meta description when I set one.
I have also looked at the file in /app/code/core/Mage/Catalog/Block/Category/View.php but nothing's there that would give me a hint on what goes wrong.
Could anyone help me get to the right direction?
EDIT: I have also tried removing the file in templates/page/html/head.phtml from my custom theme, just to see if that does anything wrong, but nothing changed after that, either.
EDIT2: My sub-categories use the parent category settings.
Old question - however I found that the following in general kills meta title
<remove name="breadcrumbs" />
Once you add that to any layout, the meta title returns blank.
New to Magento here, looking for advice in making sure I modify the correct files to limit the scope of changes and not run into any issues when updating. I installed the following extension for FAQ function:
http://www.magentocommerce.com/magento-connect/flagbit-faq.html
By default the front end FAQ page was displaying with 2 columns (1 left sidebar showing a product comparison block which was unnecessary on a FAQ page). I found the following file:
/app/design/frontend/base/default/layout/faq.xml
And changed:
<default>
<reference name="root">
<action method="setTemplate"><template>page/page/2columns-left.phtml</template></action>
</reference>
</default>
To:
<default>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
</default>
This had the desired result on the FAQ page, but also the undesired result of removing the compare box from the actual product list page. How would I best make the desired change to the FAQ page layout without impacting other pages?
Their module's faq.xml shouldn't be setting that on the default node.
Inspect the page and look for the class on body. It might be something like cms-faq (should say something about faq). Convert the dash - to an underscore _ and use that value in place of default in faq.xml
<cms_faq>
<reference name="root">
....
</cms_faq>
That should make sure the change to the setTemplate action only affects that page.
By setting default there, they are targeting all layout handles, which is really not what they should be doing in a module that just creates a new page.
Hy!
My problem is in this menu:
cambuistore.com.br/loja/index.php/
I would like others to explain why menu is duplicated in this case, because i have just one of this: getChildHtml('topMenu') ?> in my header.phtml
top.phtml & header.phtml - http://snipt.org/ujiH2
catalog.xml - http://snipt.org/ujiG8
needing any other files guys?
tks
Maybe the header block is defined twice in your layout XML?
It's impossible to tell without more information. Could you please edit your post to include your layout XML and the contents of your phtml files?
EDIT: Thanks
I've had a look over the files you've linked and I can't see any issues. The only thing I can think might be your problem is that elsewhere one of your .xml files is referencing "top.menu" and adding the block again.
In catalog.xml you have this:
<reference NAME="top.menu">
<block TYPE="catalog/navigation" name="catalog.topnav" template="catalog/navigation/top.phtml"/>
</reference>
top.menu is defined in page.xml like this:
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
<label>Navigation Bar</label>
</block>
the type: core/text_list refers to the file at app/code/core/Mage/Core/Block/Text/List.php, which goes through each of it's children blocks and renders them one by one.
If elsewhere in your xml (maybe page.xml, or something else) you're adding a top.phtml block to topMenu, then it will be rendering twice.
Let me know how you go.
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.
I am using this code in my template file to display a static block in my left sidebar:
<?= $this->getLayout()->createBlock('cms/block')->setBlockId('leftSB1')->toHtml() ?>
I would like to exclude the block from one of my CMS pages. How do I do this?
I think it requires adding code to the 'Layout Update XML' section but I'm not sure what exactly.
Someone else can correct me here, but I'm fairly sure that you're going to have trouble trying to accomplish this given the way you called the block. Normal layout updates allow you to remove blocks, but those are blocks that were also created with the layout (e.g. the Layout object knows about them after you call loadLayout()).
In your case, you create the block on the fly and then immediately use it to echo some HTML. If you want to be able to delete it with layout updates, try moving it into the layout files first, then use the normal layout block removal method:
<reference name="your_parent_block_name">
<remove name="leftSB1"/>
</reference>
Otherwise, you could hide it either in the PHP (By setting some global variable and checking it before outputting the block. Poor form but it might work.) or in CSS. Let me know if any of these work for you.
Thanks,
Joe
Include the block in your layout instead:
<cms_page>
<reference name="left">
<block type="cms/block" name="leftSB1">
<action method="setBlockId"><id>leftSB1</id></action>
</block>
</reference>
</cms_page>
And then $this->getChildHtml('leftSB1') in your sidebar, if you're not including children automatically.
(and then remove it from the particular page as in the previous answer)