Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Attempting to add structural block and content block. Please help
 
Bimmerhead
Jr. Member
 
Total Posts:  30
Joined:  2009-11-28
Atlanta, GA
 

I’m relatively new to Magento and I’ve spent the last few weeks reading this forum and wiki to grasp a better understanding of the software. However I’m failing to clearly understand some of the concepts and hope someone can help remove the confusion.

I need to create a new structural block positioned between the content and footer blocks and in this block a content block intended to display specific products which initially will be hard-coded. So far this is what I have.

In page.xml I added

<block type="core/text_list" name="specials" as="specials"/>

then in my current theme; 1column.phtml I added:

<?php echo $this->getChildHtml('specials'?>
to the existing code, resulting in:
<div class="col-main">
        
<?php echo $this->getChildHtml('global_messages'?>
        <?php 
echo $this->getChildHtml('content'?>

        <?php 
echo $this->getChildHtml('specials'?>

</div>

Now at this point my confusion begins. I then created a file named specials.xml and placed in the catalog/product folder as follows:

<reference name="specials">
    <
block type="catalog/product/specials" name="specials" />
        <
div class="page-title">
             <
strong><?php echo $this->__('Monthly Specials'?></strong>
        </
div>
</
reference>

But when I display the page I don’t see my block.

Incidentally I’m using Magento ver. 1.3.2.4 and turned off the cache, turned on Template Path Hints and Block Names.

Any help would be much appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bmotters
Member
 
Total Posts:  46
Joined:  2009-04-16
 

Sorry, but it looks like you are just stabbing in the dark.  This isn’t at all how one does what you seem to be trying to do.  There are a number of tutorials available that explain how to edit the frontend design, step-by-step. Are you following one of them?  If not, you should get one of them and follow it carefully.

However, you might try the following to get a little closer to what you want:

(1) Delete your specials.xml.  Magento is not reading it anyway.  You would have to do more configuration to get Magento to process your new config file; and what you have in that file won’t work anyway.

(2) Change what you put in page.xml. In the <default> section, within the <block type="page/html" name="root ..> block definition add the following block definition.

<block type="core/template" name="specials" template="catalog/product/specials.phtml" />

This makes the “specials” block a child of the root block and associates it with a template.

(3) Create a template file, app/design/frontend/default/default/templates/catalog/product/specials.phtml. The path might be
somewhat different if you are not editing the default frontend design.  This template file should look as follows:

<div class="page-title">
   <
strong><?php echo $this->__('Monthly Specials'?></strong>
</
div>
etcetc.

(4) Leave your edits to 1column.phtml, though this will put the “specials” block on every page that uses that template, which is probably far more pages than you imagine.

This approach will give you a block of “core/template” type, which uses a template to generate the HTML. This is the base class for all template-based blocks, including “page/html”.  This is probably not what you ultimately want, since I imagine you want to do more than just display a “Monthly Specials” heading on a page, and you won’t want it on all the many different pages that use 1column.phtml as their template.

To display product specials you are probably going to need to use a block of type “catalog/product” or perhaps even a custom block, such as in your original code.  For the latter, though, you need to do a lot more work to define a new “catalog/product/specials” block type that is a subclass of “catalog/product”.  But the approach I’ve outlined will at least work, and will get you rolling.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bimmerhead
Jr. Member
 
Total Posts:  30
Joined:  2009-11-28
Atlanta, GA
 

bmotters -

Thank you for your reply. I’ll work on this later in the week.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top