How to change the page layout in Magento? - magento

I want to change my category page layout to 2columns-left.phtml. The default is a 3 column layout. I only want to set the category page layout to 2columns-left.phtml. The rest should keep the default page layout (3 columns). How can I do this?

You can do this for categories individually under the Design tab. You can do this for all categories by adding a local.xml to your custom theme's layout folder which contains the following:
<?xml version="1.0"?>
<layout>
<my_category_root_template>
<reference name="root">
<tpl>page/2columns-left.phtml</tpl>
</reference>
<my_category_root_template>
<catalog_category_layered>
<update handle="my_category_root_template" />
</catalog_category_layered>
<catalog_category_layered_nochildren>
<update handle="my_category_root_template" />
</catalog_category_layered_nochildren>
<catalog_category_default>
<update handle="my_category_root_template" />
</catalog_category_default>
<!-- EDIT: forgot about search results page -->
<catalogsearch_advanced_result>
<update handle="my_category_root_template" />
</catalogsearch_advanced_result>
<layout>
For further info, Magebase has a great Layout XML primer, and Alan Storm wrote the book on it.

I don't have much experience with magneto but i think it may work.
Go to admin->Catalog->Categories->Manage Categories
Then go to ->Custom Design
You will find Page Layout option there change that to whatever you like.

First to set up the categories: in the admin panel, select the Catalog menu. Then on the left, select the category that you wish to edit. On the right, the Custom Design tab contains the Page Layout property. If you want all categories to have the same layout, set the root category's Page Layout accordingly, and then the child categories' "Use Parent Category Settings" property to True.
The layout for all other pages will be determined by the CMS->Pages page. Click the page to modify, then on the left, select Design, and then on the right, the Layout property.
If you are wondering how to make sure that all subsequently created pages in the CMS admin area by default use a particular layout, so that you don't have to change it each time you create a new content page, I am not certain, as mine seems to default to 1column, even though the XML seems to configure the page to use 3-column (I'm referring to what is in /app/design/frontend///layout/page.xml).. I may misunderstand how that is linked to this, though, perhaps someone else can comment. My understanding is that the CMS pages have their layout settings and custom layout information stored in the database. Therefore, perhaps there is another setting in the database that choose the default when creating a new CMS page.

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.

Magento search result links to product pages use the wrong template

I've modified my search results page to use the 2columns-right template. But all of my product pages use the 1column template.
When I click on any of the links to products in my Magento search results, the product page is displayed in the left side of the 2columns-right template. Since product pages should use the 1column template, the result looks broken.
The product pages, when linked to from search results, don't seem to retain their heirarchy in the url, either. They appear as standalone pages instead of pages within the catalog. I'm guessing that this is part of the problem.
Is there any way to retain the page heirarchy in search results? Or any way to get the different types of pages that may show up in search results to use their respective templates?
I solved it by editing this block in layout/catalog.xml:
<catalog_product_view translate="label">
<label>Catalog Product View (Any)</label>
<!-- Mage_Catalog -->
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
I just changed the template there & now the results look correct.

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.

Magento show sidebar in the customer login page

I want to show a sidebar in the left side of customer account login page. I have successfully placed the sidebar in the product page by calling the navigation bar in catlog.xml file.
But doing the same method with the customer.xml file is not showing the sidebar.
Note
By going through the post "Magento: Display Categories in Sidebar" I had changed my sidebar in product page. But its not working for customer login page.
You need to first tell Magento to use the 2 column template for the Customer Account Login page - as standard it uses the 1 column template file and as such wont have either the left or right structural blocks for your sidebar to go into.
Simple to do - best practice would be to add the layout instruction to an existing or create a local.xml file in your app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout/ folder.
Using the handle <customer_account_login> so as to reference the login page, add the following to local.xml
<customer_account_login>
<reference name="root">
<action method="setTemplate"><template>page/2column-left.phtml</template></action><!-- Tells Magento to use 2 Column Left page template -->
</reference>
</customer_account_login>
This will use the template with a left sidebar.
Then, also within the same <customer_account_login> handle call in your block to the left structural block...
<customer_account_login>
<reference name="root">
<action method="setTemplate"><template>page/2column-left.phtml</template></action><!-- Tells Magento to use 2 Column Left page template -->
</reference>
<reference name="left"><!-- Tells Magento to place the following content in the left structural block-->
<!-- Your Block Goes Here -->
</reference>
</customer_account_login>
Done.
If you're not comfortable working in a local.xml file you can just amend the content of the <customer_account_login> handle in customers.xml to use the above mentioned "root" and "left" - you'll find it calls the page/1column.phtml file under root and of course wont yet have a <reference name="left">.

Resources