Magento looks in base folder and not in Theme Folder - magento

i've try to do this in so many ways and keep getting the same results, this is what i'm doing:
under
app/design/frontend/default/new-theme/layout/
i have created a local.xml to replace some code:
<?xml version="1.0"?>
<layout>
<catalog_product_view translate="label">
<reference name="content">
<block type="catalog/product_view" name="product.info" template="catalog/product/new-view.phtml">
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/new-media.phtml"/>
<block type="catalog/product_view" name="product.info.addto" as="addto" template="catalog/product/view/addto.phtml"/>
<block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/new-addtocart.phtml"/>
</block>
</reference>
</catalog_product_view>
</layout>
The problem is when i go to the product page to check Template Path Hints is telling me that Magento is looking for the template in
frontend/base/default/template/catalog/product/new-view.phtml
In the backend i have setup templates, css and translations to come from new-theme folder.
Can anyone tell me where am i doing wrong?
Thanks

Your local.xml may not be read.
Try adding your layout to page.xml where needed.
Or flush cache.
Use the following to get a dump of any page's built xml to further troubleshoot:
$oRequest = Mage::app()->getRequest();
$info = sprintf(
"\nRequest: %s\nFull Action Name: %s_%s_%s\nHandles:\n\t%s\nUpdate XML:\n%s",
$oRequest->getRouteName(),
$oRequest->getRequestedRouteName(), //full action name 1/3
$oRequest->getRequestedControllerName(), //full action name 2/3
$oRequest->getRequestedActionName(), //full action name 3/3
implode( "\n\t", Mage::app()->getLayout()->getUpdate()->getHandles() ),
Mage::app()->getLayout()->getUpdate()->asString()
);
// Force logging to var/log/layout.log
Mage::log($info, Zend_Log::INFO, 'layout.log', true);
#per Alan Storm

Related

how to insert my custom template file in list page using xml without using getChild html and not rewrite list.phtml

This is how i tried. bud didn't get answer. what my template will do is each product image will have a like button. i have done with view.phtml but not in list.phtml. Pls friends broadcast your knowledge.
<reference name="content">
<block type="productlike/most" name="productlike" before="-">
<action method="setTemplate" ifconfig="section_1/group_1/enabled"><template>productlike/like.phtml</template>
</action>
</block>
</reference>

How to place my custom block inside another block in Magento using layout xml?

first of all I want to say that I have searched for this whole day on te internet and could not find what I wanted. I am a newbie here as well, so please forgive me if I broke any rule.
I am trying to develop a module which will add videos to product page along with images. I am stuck in this concept:
How do I insert my block into an existing base block ? For example, in the product page, there is a block product.info. Inside this block there is "Availability", "Price" etc.
How do I insert my custom block just below "Availability" and above "Prices" using my module's layout xml and template.
So I am trying to achieve something like this using my module's layout file:
<catalog_product_view translate="label">
<reference name="content">
<reference name="product.info">
WRITE BLOCK HERE SO THAT MY BLOCK SHOWS BELOW AVAILABLITY
</reference>
</reference>
</catalog_product_view>
Is this possible ? or Do I have to override the core class Mage_Catalog_Block_Product_View to do this ?
PS: Basically my aim is to list my videos next to images. Right now, I am able to list my videos from module, but images don't come in that case. I used
<block type="myblock/myblock" name="somename" as="media" template="abc.phtml"/>
So I want to append my block to the existing content.
I solved it. I had to rewrite the Mage_Catalog_Block_Product_View_Media .
In my class I over-rid the function _toHtml function like this:
public function _toHtml()
{
$html = parent::_toHtml();
$html.=$this->getChildHtml('media_video');
return $html;
}
where "media_video" is my block. My layout xml file:
<catalog_product_view translate="label">
<reference name="content">
<reference name="product.info">
<reference name="product.info.media">
<block type="myblock/myblock" name="somename" as="media_video" template="beta/abc.phtml"
before="-"/>
</reference>
</reference>
</reference>
</catalog_product_view>
You can add new block instead of over-right existing.
<catalog_product_view translate="label">
<reference name="content">
<reference name="product.info">
<block type="myblock/myblock" name="somename" as="media_new" template="abc.phtml"/>
</reference>
</reference>
</catalog_product_view>
Get New Block using following code in phtml file
<?php echo $this->getChildHtml('media_new') ?>
Thanks
Note output="toHtml" in the below code. This will print your block in product.info section.
<catalog_product_view translate="label">
<reference name="content">
<reference name="product.info">
<block type="myblock/myblock" name="somename" as="media"
template="abc.phtml" output="toHtml" before="-" />
</reference>
</reference>
</catalog_product_view>

What is preventing my layout updates from being displayed

I am trying to display a simple message on my Magento site using a special block that I have created. I have been able to easily unset blocks and insert them in other places on the home page, but I am running into trouble when I try to do the same thing on one of the product pages. I have created a file at app/design/frontend/base/default/layout/packagename/modulename.xml
with the following contents:
<?xml version="1.0"?>
<layout>
<default>
<reference name="product.info">
<block type="core/text" name="free_shipping">
<action method="setText"><text><![CDATA[<div>Free Shipping!</div>]]> </text></action>
</block>
</reference>
<reference name="header">
<action method="unsetChild">
<name>top.search</name>
</action>
</reference>
</default>
</layout>
It seems to me like the code above would remove the search bar from a product page and add a block in the product info section that says "Free shipping!" but when I load the page there are no changes. I have tried using "remove" to alter some of the blocks on the page and it works, so the file is definitely being loaded into the layout.xml. I have also tried making my changes in the local.xml file instead, with the same results. Other than that, I am kind of at a loss for things to try to get this to work correctly.
Edit: To provide some more information on the problem, if I were to replace my changes with something like
<reference name="root">
<action method="unsetChild">
<name>header</name>
</action>
</reference>
The header is sucessfully removed. So I guess the question now is, why does calling unset child work as expected when used on the "root" block but not on "header"?
I think you need to be more specific with your layout handler, you are setting it as and that means all pages, i recommend you change that handler by
<?xml version="1.0"?>
<layout>
<catalog_product_view>
<reference name="product.info">
<block type="core/text" name="free_shipping">
<action method="setText"><text><![CDATA[<div>Free Shipping!</div>]]> </text></action>
</block>
</reference>
<reference name="product.info">
<block name="header">
<action method="unsetChild">
<name>top.search</name>
</action>
</block>
</reference>
</catalog_product_view>
</layout>
Greetings.
First of all, never put your stuff in the base/default folder.
On to your question. What if you try it like this:
<reference name="header">
<action method="unsetChild">
<name>top.search</name>
</action>
</reference>
To answer your other question:
The header is sucessfully removed. So I guess the question now is, why does calling unset child work as expected when used on the "root" block but not on "header"?
It's not the fact it's on the root block, it's that you should use unsetChild within the <reference/> part.

Magento: Change the block template in local.xml

I would like the product reviews page to use a different template instead of:
catalog/product/view.phtml
In review.xml, I see the file being called:
<block type="review/product_view" name="product.info" template="catalog/product/view.phtml">
Is there a way I can override that in local.xml and create a new file (ex: view2.phtml) and use that for this page?
<review_product_list>
<reference name="product.info">
<action method="setTemplate"><template>catalog/product/view2.phtml</template></action>
</reference>
</review_product_list>
Yes, you can definitely do that by writing the following code in local.xml:-
<reference name="product.info">
<action method="setTemplate"><template>catalog/product/view2.phtml</template></action>
</reference>
Here view2.phtml is your new file in the proper folder structure.
Hope it helps.

Magento template not loaded properly

I created a new module and I try to load a template in an action under indexcontroller. That template loaded properly but the basic/root templates are not loaded. Magento loaded only the template file what I specified in the XML. I explained the steps below what I followed.
Create a module named 'Sample'.
Create a IndexController with a index action.
Create local.xml file under the dir app/design/frontend/default/default/layout/
Create sample_page.phtml under the dir app/design/frontend/default/default/template/sample/sample_page.phtml.
IndexController:
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
local.xml:
<layout version="0.1.0">
<default>
</default>
<sample_index_index>
<reference name="root">
<block type="page/html" name="root" output="toHtml" template="sample/sample_page.phtml">
</block>
</reference>
</sample_index_index>
Could anybody find the issue what I done?
The issue here is that you referenced the wrong layout block ("root" in your example). Doing that replace the entire set of blocks for page by the one you specify.
To get all the blocks displayed (included yours), simply reference another layout block than "root", for example "content".
You could also want to modify the root layout block for pages of your module, if that is the case, in the default handle, reference the root block and set a different template.
Here is an example :
<layout version="0.1.0">
<default>
<reference name="root">
<action method="setTemplate">
<template>page/1column.phtml</template>
</action>
</reference>
</default>
<sample_index_index>
<reference name="content">
<block type="page/html" name="the_name_you_like" output="toHtml" template="sample/sample_page.phtml">
</block>
</reference>
</sample_index_index>
</layout>

Resources