I'm pretty new to Magento, and have been following the base theme so far along, but I am having problems with catalog pagination.
At the moment I'm having problems getting the "page/html_pager" block to display.
So, my catalog.xml has this for both anchor and non-anchor categories:
<reference name="content">
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager" />
</block>
</block>
</block>
</reference>
My toolbar.phtml has the corresponding code:
<?php echo $this->getPagerHtml() ?>
and my default/template/page/html/pager.phtml just contains some test code along the lines of:
<h1>Test</h1>
At first I thought it might be because there weren't multiple pages, so I added some products and set the both the grid and the list views to show a maximum of 1 per page, and the item count reflects this:
Showing 1 of 11 items
Doing a var_dump on the $this->getPagerHtml() returns an empty string, and using the template path hints indicates it doesn't even seem to load the block - yet it loads it's parent block.
Copying the code directly from the base design package doesn't work, yet switching to that package it does.
So, what am I missing? Or doing wrong? I've run out of ideas as to what it could be.
thanks
Solved:
Adding<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
After the product_list_toolbar block appeared to fix this issue.
Magento's documentation is a little thin on the ground with this so I'm unsure as to why
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
requires it's name set again with an action tag, but it does.
If anyone can explain this, I'd love to understand it.
Any chance that it's being overridden by a different .xml file in layout?
You could always remove all the .xml files in the layout directory and bring them back in one by one and see if the pagination toolbar disappears, whilst making sure cache is turned off.
After that, rename the template directory catalog to ~catalog and let it pick up the base catalog directory and see if it's actually the .phtml files causing the problem.
Related
I followed this tutorial to create the custom block in magento
http://www.gravitywell.co.uk/blog/post/how-to-creating-your-own-custom-block-in-magento
But nothing is showed when I open up home page or any other page. I have searched alot on web but unable to solve the issue.
The above tutorial did not mention where to create layout.xml file but I have created it at:
app\design\frontend\gravitywell\example\layout\layout.xml ---It has just following code:
<block type="gravitywellexample/menu" name="menu" as="menu" template="gravitywell/menu.phtml" />
Any help will be highly appreciated.
Thanks in advance.
I would use local.xml, but then the question becomes what handle tags to put it inside of i.e. where do you want it to show up. When using a 2column-right layout, I can position it inside of the right column on the product page this way:
<catalog_product_view>
<reference name="right">
<block type="gravitywellexample/menu" name="menu" as="menu" template="gravitywell/example/menu.phtml" />
</reference>
</catalog_product_view>
my template is stored in a slightly different folder.
hth, sconnie
I'm trying to remove "recently viewed" from the home page, but I don't know where the block is called. I tried to delete reports.xml but the block stayed there. Then I tried to delete all the code in home_product_viewed.phtml and it worked, but I don't want to delete the code. I only want to delete the call to that file but I don't know where that file is called.
Goto magento backend.
Select the CMS page for homepage.
In the Design section add the below code in the Layout Update XML field
<reference name="right">
<action method="unsetChild"><alias>right.reports.product.viewed</alias></action>
</reference>
To remove it from only the home page, I would do this. Go to your /app/design/frontend/packagename/themename/layout/local.xml
and edit it like this:
<layout>
<cms_index_index>
<remove name="right.reports.product.viewed" />
</cms_index_index>
</layout>
To verify your packagname and themename, go in to admin - System - Configuration - Design.
There may already be other code inside of the layout tag which you should leave there!
This worked for me -> Using left below not right.reports.product.viewed.
Custom Layout Update
<reference name="right">
<action method="unsetChild"><alias>left.reports.product.viewed</alias></action>
</reference>
I’m having trouble in moving the mini cart from sidebar to header. I’ve tried all the tutorials available in the internet but it doesn’t work.
I also tried adding this in the header block of layout\page.xml
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/sidebar.phtml"
And then in my page\html\header.phtml, I use the code below to call the cart but nothing happened.
<?php echo $this->getChildHtml('topcart'); ?>
The solution above works in magento 1.6, but not in version 1.7
First you need to create or update your local.xml file IF you do not have a local.xml file you can create one in
app->frontend->[Package Name]->[Theme Name]->layout->local.xml
Once this is created you can copy exactly what I have in this post into that file for a start of how to use one.
DO ALL UPDATES THROUGH A LOCAL.XML file not through catalog.xml or checkout.xml !! This will make upgrades significantly easier later down the road. Additionally, you will be able to quickly see all changes you have made to your site in one file.
The below example will add it to the header reference name which will be available on all pages as indicated by the tag and will only be available in the header.phtml file. Duplicate base/default/checkout/cart/sidebar.phtml and rebane that file as topcart.phtml and place it into your theme at [Your Package]/[Your Theme]/template/checkout/cart/topcart.phtml by doing this you are cloning the sidebar functionality and adding it to the header. Then you can make any edits through the topcart.phtml file without affecting base functionality.
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="header">
<block type="checkout/cart_sidebar" name="topcart_mini" as="topcart" template="checkout/cart/topcart.phtml" />
</reference>
</default>
</layout>
Then call it in header.phtml with
<?php echo $this->getChildHtml('topcart'); ?>
This is the proper way to modify Magento, this makes upgrades quite simple. Additionally, it does not edit any core files.
Insteat of copying block xml, you should reference it like
<reference name="block-name">
</reference>
I am developing a new custom module in magento. I need to customize the shopping cart page without affecting the original cart.phtml. My module name is Stallioni. I have placed the cart.phtml inside frontend/default/default/template/stallioni/checkout/cart.phtml .How can i use this cart.phtml in my new module instead of the original . I know we should change something in checkout.XML or stallioni/layout/stallioni.xml file. But no idea since i am new.I googled out a day but couldn't find.
http://blog.chapagain.com.np/magento-overriding-template-file-from-custom-module/ this link tells something but it didn't worked for me.I need your help!
If your layout.xml is working add this code in your layout
`<checkout_cart_index>
<reference name="content">
<reference name="checkout.cart">
<action method="setTemplate">
<template>default/default/template/stallioni/checkout/cart.phtml</template>
</action>
</reference>
</reference>
</checkout_cart_index>`
It should work :)
I asked this question yesterday Static block on home page in Magento, which answered my question about hooking a cms/block to an existing block (content, in that example).
But now I would like to know how to create my own block.
I have this in my .phtml template:
<?php echo $this->getChildHtml('home_flash') ?>
And this in my cms.xml file
<reference name="home_flash">
<block type="cms/block" name="home-page-flash" before="content">
<action method="setBlockId"><block_id>home-page-flash</block_id></action>
</block>
</reference>
But this is not working.
I have also tried to create my own block type, (by copying the breadcrumbs declaration) in the page.xml file:
<block type="page/html_home_block" name="home_block" as="home_block" template="page/template/home_block.phtml"/>
That file exists but isn't being rendered.
However when I reference the block like this:
<block type="page/html_breadcrumbs" name="home_block" as="home_block" template="page/template/home_block.phtml"/>
It renders my home block template, but the original cms/block is not attached to it.
Hope all the different cases show what is happening and highlight the gap in my knowledge well enough for someone to answer, do I have to "register" my new "home_block" type somewhere?
There are many different blocks available that you can use without creating your own. In this case I think core/text_list would be suitable because it doesn't require a template and can have as many child blocks within it as you need.
<?xml version="1.0"?>
<layout version="0.1.0"><!-- All layout files start with this -->
<cms_index_index><!-- Index directive is the same as "home" page -->
<reference name="root"><!-- For more blocks that can be referenced see "default" directive -->
<block type="core/text_list" name="home_flash">
<block type="cms/block" name="home-page-flash">
<action method="setBlockId"><block_id>home-page-flash</block_id></action>
</block>
</block>
</reference>
</cms_index_index>
<!-- More directives might go here -->
</layout>
Other useful block types worth knowing are core/text and core/template which correspond to Mage_Core_Block_Text and Mage_Core_Block_Template respectively. They get used the most.
Your home made block type of page/html_home_block didn't have any PHP class with a matching name, and if you were genuinely creating your own you wouldn't be able to use the page prefix since Magento already does.
To create a block you only need a <block> tag in the layout file.
To create a block type you need to write a PHP class, give it a namespace and declare it as part of a module.
To add to an existing block is the time when you use a <reference> tag.
There are many fine articles at Magento Knowledge Base including some on Theming & Design.