Call-back icon  Questions? Contact our sales team to a request a quote

Magento

eCommerce Software for Online Growth

Magento Forum

   
Create a new block
 
Sam Boson
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2007-11-15
 

Sorry if this has been answered anywhere else, I have looked and I don’t think it has, if you know better please enlighten me.

We are putting together a small shop in Magento, and on the parent category page we wish to create a listing of all the categories, don’t ask why or point out the potential for this mucking up I’m well aware but client is king.

I’m not having a problem getting the listing to work or with creating a new template layout in order to achieve this however, I don’t seem to be able to define the block itself.

I have added the layout in /app/code/core/Mage/Cms/etc/config.xml using the format:

<rightcategory_column>
    <
label>Category column on the right</label>
    <
template>page/2columns-rightcategories.phtml</template>
</
rightcategory_column>

And I’ve got the parent category set to use this template and it is finding the files correctly.

Within that template I am referencing my category listing using the following:

<?=$this->getChildHtml('categorylisting')?>

And I have added the following block to the /app/design/frontend/default/layout/main.xml:

<reference name="rightcategory">
        <
block type="core/template" name="catalog.listing" template="catalog/category/listing.phtml" as="categorylisting" />
</
reference>

But this isn’t working, any ideas? Am I being a numpty?

Thanks in advance for any help of advice given.

Sam

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sam Boson
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2007-11-15
 

I seem to be getting plenty of views but no replies, if any one else is having this problem please say so, if for no other reason than to reassure me that I not a complete idiot.

Alternatively if I am being a complete idiot please tell me so and (this bit is important) point me in the direction of some further reading which would help me, or offer a suggestion.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1771
Joined:  2007-08-07
Los Angeles
 

Hi, I’ve started writing response but the browser crashed and I’ve forgot about it.. Anyways, short version smile :

<reference name="block_name"> should have Existing block name that you want to apply changes to, which in this case should be “right, so try:

<reference name="right">
        <
block type="core/template" name="catalog.listing" template="catalog/category/listing.phtml" as="categorylisting" />
</
reference>

 Signature 

- I would love to change the world, but they won’t give me the source code -

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sam Boson
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2007-11-15
 

Thanks Moshe,

I don’t want to change right as that is being used elsewhere, what I have done is create a new template which utilises a different new block called right categories. I have got this working but I want to go back through my changes and weed out any unneeded updates before I post here.

Cheers again

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sam Boson
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2007-11-15
 

To any one that is interested, I hope this is useful but this is how I’ve created my new block.

First I created the block file itself in my case /app/design/frontend/default/default/template/catalog/category/listing.phtml

Then I reference it in the main.xml file (/app/design/frontend/default/default/layout/main.xml) by adding the following lines:

Within the root block definition:

<block type="core/text_list" name="rightcategory" as="rightcategory">
        <
block
                type
="catalog/category_listing"
                
name="category.listing"
                
template="catalog/category/listing.phtml"
                
as="categorylisting" />
</
block>

Within the Mage Catalog section:

<reference name="rightcategory">
        <
block
                type
="catalog/category_listing"
                
name="category.listing"
                
template="catalog/category/listing.phtml" />
</
reference>

Then created my new template file (/app/design/frontend/default/default/template/page/2columns-rightcategories.phtml) which was basically a duplicate of 2columns-right.phtml where the ‘right’ block call was replaced by the following code.

<?=$this->getChildHtml('rightcategory')?>

Then registered my new template in /app/code/core/Mage/Cms/etc/config.xml by inserting the following code into the layouts tag:

<rightcategory_column>
    <
label>
        
Category column on the right
    
</label>
    <
template>
        
page/2columns-rightcategories.phtml
    
</template>
</
rightcategory_column>

This then allowed me to create my Mage_Catalog_Category_Listing block class and my listing.phtml template.

Then I selected my new template in the CMS for the category concerned and bingo bango it all worked.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
60012 users|867 users currently online|118870 forum posts