Magento overriding template file doesnt work - magento

In ShopShark(this module for blog) i have this code
<?xml version="1.0"?>
<layout version="0.1.0">
//a lot of code//
<blog_post_view>
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="blog/post" name="post" template="blog/post.phtml">
<block type="blog/product_toolbar" name="blog_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
</block>
</reference>
</blog_post_view>
// a lot of code //
</layout>
Next i try to change post page. I found the solution here http://blog.chapagain.com.np/magento-overriding-template-file-from-custom-module/ , but its doesnt work! My code
<?xml version="1.0"?>
<layout version="0.1.0">
//a lot of code//
<blog_post_view>
<action method="setTitle">
<title>My Blog</title>
</action>
<reference name="post">
<action method="setTemplate">
<template>test/post.phtml</template>
</action>
</reference>
</blog_post_view>
// a lot of code //
</layout>

What you are exactly trying to do is not clear.I think you messed up with the structural block here. I am not exactly sure but needed to see the xml file where you have created the block "post".If you have not created the block "post",then you cannot use the code
<reference name="post">
From your code it seems that you are trying to change the template to post.phtml.
If that is the case than just change
<reference name="post">
to <reference name="content">
other part seem fine.
Hope this will help!

Related

Magento tab order in admin customer edit

With the following code, the 'myinfo' tab is added tie the customer edit page, but it appears a second element after the 'customer view'.
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_customer_edit>
<reference name="left">
<reference name="customer_edit_tabs">
<block type="mystuff/adminhtml_customer_edit_tab_myinfo" name="tab_points"
template="my/stuff/customer/myinfo.phtml">
...
</block>
<action method="addTab">
<name>my_stuff</name>
<block>tab_myinfo</block>
<!-- TODO find way to change sequence of tab added -->
</action>
</reference>
</reference>
</adminhtml_customer_edit>
</layout>
...I'd like to add a screenshot... but my reputation is too low :(
How can the sequence of appearance be defined? I tried the following:
1. <action method="addTab" after="cart">
...
2. <action method="addTab">
<after>cart</after>
...
3. <action method="addTab">
<sequence>999</sequence>
...
... but no change

Override AddItemRenderer default in Admin Magento Extension

I've created a magento (1.7 CE) local module to add, in the Admin section, some info to the product list displayed in the Orders received.
Internally all seems to work good except that i'm not succeeding in replacing the template used to render each product line in the order.
In app/design/adminhtml/default/default/layout/sales.xml i have this code
<adminhtml_sales_order_view>
<reference name="head">
<action method="addJs"><file>mage/adminhtml/giftmessage.js</file></action>
<action method="addJs"><file>mage/adminhtml/giftoptions/tooltip.js</file></action>
</reference>
<reference name="content">
<block type="adminhtml/sales_order_view" name="sales_order_edit"></block>
</reference>
<reference name="left">
<block type="adminhtml/sales_order_view_tabs" name="sales_order_tabs">
<block type="adminhtml/sales_order_view_tab_info" name="order_tab_info" template="sales/order/view/tab/info.phtml">
<block type="adminhtml/sales_order_view_messages" name="order_messages"></block>
<block type="adminhtml/sales_order_view_info" name="order_info" template="sales/order/view/info.phtml"></block>
<block type="adminhtml/sales_order_view_items" name="order_items" template="sales/order/view/items.phtml">
<action method="addItemRender"><type>default</type><block>adminhtml/sales_order_view_items_renderer_default</block><template>sales/order/view/items/renderer/default.phtml</template></action>
<...
I would like to replace the template set by the LAST line you see (the addItemRenderer).
In my module config.xml i have
<adminhtml>
<layout>
<updates>
<my_ext>
<file>myext_update.xml</file>
</my_ext>
</updates>
</layout>
</adminhtml>
and in app/design/adminhtml/default/default/layout/myext_update.xml i have
<?xml version="1.0"?>
<admin_sales_order_view>
<reference name="left">
<reference name="sales_order_tabs">
<reference name="order_tab_info">
<reference name="order_items">
<action method="addItemRender">
<type>default</type>
<block>adminhtml/sales_order_view_items_renderer_default</block>
<template>myext/sales/order/view/items/renderer/default.phtml</template>
</action>
</reference>
</reference>
</reference>
</reference>
</admin_sales_order_view>
Obviously i have the file in app/design/adminhtml/default/default/template/myext/sales/order/view/items/renderer/default.phtml
but it is still not used.
Do you have a solution?
Found the solution after some day of struggling...
the code and the method is all good, but i mistyped the handle name to update in the myext_update.xml
i wrote
<admin_sales_order_view>
but , as in the original sales.xml, the handle name was
<adminhtml_sales_order_view>
Actually this wont work as the way you proceeded. You need to update the layouts.
Have some idea about layout updates also render the layout in yout module
Check here http://www.magentocommerce.com/design_guide/articles/intro-to-layouts

Cannot override block template in magento

I have read quite many posts, but for me nothing is working. Task is quite simpe - I need to override core template review/product/view/list.phtml with my own, let's say my_list.phtml
My configuration is as follows. Layout.xml (head modification is working)
<layout version="0.1.0">
<review_product_list>
<reference name="head">
..
</reference>
<reference name="product.info">
<block type="review/product_view_list" name="myreview.product_additional_data"
as="myreview_product_additional_data" template="review/product/view/my_list.phtml"/>
</reference>
</review_product_list>
Config.xml
<frontend>
<layout>
<updates>
<myreview>
<file>myreview/layout.xml</file>
</myreview>
</updates>
</layout>
</frontend>
I can change core file review.xml and it works as expected, this line
<block type="review/product_view_list" name="product.info.product_additional_data" as="product_additional_data" template="review/product/view/list.phtml">
but this is not I am expecting.
If I change
reference name="product.info"
to
reference name="content" My template shows up, but not in place. If I try to debug, blocks are rendered.
<review_product_list>
<reference name="product.info.product_additional_data">
<action method="setTemplate">
<tpl>review/product/view/my_list.phtml</tpl>
</action>
</reference>
</review_product_list>
or
<review_product_list>
<action method="setTemplate" block="product.info.product_additional_data">
<tpl>review/product/view/my_list.phtml</tpl>
</action>
</review_product_list>

Create a module in magento

I have followed the magento tutorials to create a module. In the 3rd part "Part 3 - Magento Controller Dispatch". I have no problem to create a module.But in the Part 4, i am confusing about the layout,
How to create a page template in magento is written there.But, When i followed the code "create a file at"
app/design/frontend/base/default/layout/local.xml
I have already the local.xml file in my theme. So i confused where can i create the file and add the lines
<layout version="0.1.0">
<default>
<block type="page/html" name="root" output="toHtml" template="magentotutorial/helloworld/simple_page.phtml" />
</default>
</layout>
I have already the local.xml file where the following lines are written.
left.permanent.callout
<reference name="right">
<action method="unsetChild"><name>right.permanent.callout</name></action>
<remove name="paypal.partner.right.logo"/>
</reference>
<reference name="root">
<remove name="global_messages" />
</reference>
<reference name="content">
<block type="core/template" name="alert_global_messages" template="core/messages.phtml" before="-" />
</reference>
<reference name="before_body_end">
<block type="core/template" name="jquery_noconflict" template="jquery/noconflict.phtml" before="-" />
</reference>
Now, how can i add the line
in my local.xml file.

remove recent viewed products in magento won´t work

Hello I tried to remove the recent viewed product via local.xml, but it did not work and I don´t know why. Here my code:
<?xml version="1.0"?>
<reference name="right">
<action method="unsetChild"><alias>right.reports.product.viewed</alias></action>
<action method="unsetChild"><alias>right.reports.product.compared</alias></action>
</reference>
<default>
<action method="unsetChild"><name>right.reports.product.viewed</name></action>
<action method="unsetChild"><name>right.reports.product.compared</name></action>
<remove name="right.reports.product.viewed"/>
<remove name="right.reports.product.compared"/>
</default>

Resources