cancel
Showing results for 
Search instead for 
Did you mean: 

Block is not displaying

Block is not displaying

i created a block of code and called it in reference block in the Home Page(CMS Page). i created a phtml file productslider in custom_theme_directory/catalog/slider/. This file prints category Id. It is just for testing the block.

The below given block is what I created

<block type="catalog_slider/productslider" name="featuredProduct" template="catalog/slider/productslider.phtml">
<action method="setCategoryId"><category_id>3</category_id></action>
<action method="setProductCount"><product_count>10</product_count></action>
<action method="setTitle"><title>Featured Products</title></action>
</block>

But it does not display anything on the screen. I don't see any errors. I don't know what went wrong.

But when I use the below given default magento block, the product is displayed.

<block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>3</category_id></action>
<action method="setColumnCount"><count>5</count></action>
</block>

 Can anyone explain what is wrong with my code or what am I missing. I am a beginner in magento. Please help. Thanks.

2 REPLIES 2

Re: Block is not displaying


Add the provided code in your magento CMS Home Page
Goto Admin panel CMS >> Pages. Select your home page.

Here is a Tile named Page Information on the left side, select Design Tab and add the below code into "Layout Update XML" at the end.

 

<reference name="content">
<block type="core/template" name="featured_product" template="catalog/product/featured.phtml">
<action method="setColumnCount"><columns>4</columns></action>
<action method="setItemLimit"><limit>6</limit></action>
</block>
</reference>

Save the configuration.

 

Create file named featured.phtml on the below path:

app\design\frontend\mypackage\mytheme\template\catalog\product\featured.phtml

Add your content which you want to display on front end (i.e Homepage).

 

Let me know if you face any query/conern regarding this.

Query solved? Accept as Solution.Thanks
Eric Baily

Re: Block is not displaying

 Let us take this line

 

<block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">

 

When you navigate to /app/code/core/Mage/Catalog/Block/Product/

 

 block type could be viewed by their path given.

 

"product_list" is the class name that ends with.

 

So the class name for the file /var/www/heatshield/app/code/core/Mage/Catalog/Block/Product/List.php is Mage_Catalog_Block_Product_List

 

Naming convention is very important in magento and it complex too.

In your xml <block type="catalog_slider/productslider" name="featuredProduct" template="catalog/slider/productslider.phtml">

Do you have that path in your block and class name?

 

I will guide a easy way. search google for "magento module creator" and you will get a site by "silksoftware".

 

Use this site to create various modules with combination of option. You will understand the layout names and path. Its like "what you give as what you see".

 

Hope this helps.