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

Show short description on front page? 
 
MazeDK
Member
 
Total Posts:  68
Joined:  2008-10-21
 

Hi,

I’m new to Magento, and is working on customizing the web shop, so it will fit my needs. I have used this forum a lot, and have found lots of answers to my questions, but this one has got me stuck..

I want to show the short description of my products on the front page, below the pictures of the newly added products. So under each picture of the new product, the description will show. Therefor I thought that i could just take the bit of code from the file catalog/product/view.phtml

<?php if ($_product->getShortDescription()):?>
                
<h4><?php echo $this->__('Quick Overview'?></h4>
                <
div class="short-description"><?php echo nl2br($_product->getShortDescription()) ?></div>
            
<?php endif;?>

But when I paste that piece of code in the file catalog/product/new.phtml (which is included on my front page with help from the code below) there is still no short description under the pictures. It seems like it can’t figure out which short description it has to show..

<reference name="content">
<
block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml" after="cms_page"/>
</
reference>

Does any one have an idea to fix my problem?

Hope my question is understandable… Thanks in forehand!

Regards,
Mads

 
Magento Community Magento Community
Magento Community
Magento Community
 
Discovery
Enthusiast
 
Total Posts:  767
Joined:  2007-12-29
 

Get rid of your ‘if’ construct, it’s wrong! Just put <?php echo nl2br($_product->getShortDescription()) ?> and all will be fine. Don’t bother with ‘quick overview’ text either…

 
Magento Community Magento Community
Magento Community
Magento Community
 
MazeDK
Member
 
Total Posts:  68
Joined:  2008-10-21
 
Discovery - 30 November 2008 04:19 PM

Get rid of your ‘if’ construct, it’s wrong! Just put <?php echo nl2br($_product->getShortDescription()) ?> and all will be fine. Don’t bother with ‘quick overview’ text either…

First sorry for my late reply - it did not receive any notification regarding your answer. Furthermore I have made a typo in my first post - i mean new.phtml and not view.phtml.

When pasting <?php echo nl2br($_product->getShortDescription()) ?> in new.phtml the short description does not show up… And I don’t get any errors either. I have pasted it in the end of new.phtml:

<?php endif; ?>
                    [b]<?php 
echo nl2br($_product->getShortDescription()) ?>[/b]
                
</p>
            </
td>
    
<?php $i++; endforeach; ?>
    <?php 
for($i;$i%5!=0;$i++): ?>
            
<td>&nbsp;</td>
        
<?php endfor ?>
        
</tr>
    </
table>
</
div>
<?php endif; ?>

Any suggestions?

Regards,
Mads

 
Magento Community Magento Community
Magento Community
Magento Community
 
Discovery
Enthusiast
 
Total Posts:  767
Joined:  2007-12-29
 

New.phtml - now that’s different! I am not using that one, however, does it show short descriptions in the list mode? There are ways to pull through and populate the ‘product arrays’ and your new.phtml just might not be requesting everything - it’s an XML thingy to pull through non standard attributes.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MazeDK
Member
 
Total Posts:  68
Joined:  2008-10-21
 
Discovery - 03 December 2008 10:23 AM

New.phtml - now that’s different! I am not using that one, however, does it show short descriptions in the list mode? There are ways to pull through and populate the ‘product arrays’ and your new.phtml just might not be requesting everything - it’s an XML thingy to pull through non standard attributes.

It is globally set up to show as list, and there is no short description when using new.phtml. It is showing the short description, when viewing the catalog view.

All I want to, is to show the 5 newest products on my front pages, in list-view, with a short description to the right of the picture. Do you have any idea to what file I should use instead of new.phtml?

Regards,
Mads

 
Magento Community Magento Community
Magento Community
Magento Community
 
MazeDK
Member
 
Total Posts:  68
Joined:  2008-10-21
 

I just experimented a bit. I found this bit of code in a thread on the forum:

<?
            $custom 
Mage::getModel('catalog/product')->load($_item->getProductId());
            echo 
$custom->getShortDescription(); 
?>
http://www.magentocommerce.com/boards/viewthread/19187/

But when pasting it in new.phtml I get this error:

Fatal errorCall to a member function getProductId() on a non-object in shop\app\design\frontend\default\default\template\catalog\product\new.phtml on line 76

Does any one know what the solution to this error is?

Regards,
Mads

 
Magento Community Magento Community
Magento Community
Magento Community
 
MazeDK
Member
 
Total Posts:  68
Joined:  2008-10-21
 

Any ideas?

Best regards,
Mads

 
Magento Community Magento Community
Magento Community
Magento Community
 
MazeDK
Member
 
Total Posts:  68
Joined:  2008-10-21
 
MazeDK - 15 December 2008 08:31 AM

Any ideas?

Best regards,
Mads

Still no one with good ideas?

Best regards,
Mads

 
Magento Community Magento Community
Magento Community
Magento Community
 
dan_w
Sr. Member
 
Total Posts:  290
Joined:  2008-01-04
 

Take a look at app->code->core->Mage->Catalog->Block->Product->New.php. This is where the select statement is defined for the new.phtml file. You should see something similar to the following two lines:

->addAttributeToSelect(array('name''price''small_image'), 'inner')
            ->
addAttributeToSelect(array('special_price''special_from_date''special_to_date'),

After ‘name’, add ‘short_description’. It’s probably best to mirror the folder structure under local so you don’t overwrite anything and also so your changes aren’t overwritten on upgrades. Now that the ‘short_description’ is added to the select statement, you can call it from your template file using your original method.

Hope that helps,
Dan

 
Magento Community Magento Community
Magento Community
Magento Community
 
MazeDK
Member
 
Total Posts:  68
Joined:  2008-10-21
 
dan_w - 05 January 2009 02:28 PM

Take a look at app->code->core->Mage->Catalog->Block->Product->New.php. This is where the select statement is defined for the new.phtml file. You should see something similar to the following two lines:

->addAttributeToSelect(array('name''price''small_image'), 'inner')
            ->
addAttributeToSelect(array('special_price''special_from_date''special_to_date'),

After ‘name’, add ‘short_description’. It’s probably best to mirror the folder structure under local so you don’t overwrite anything and also so your changes aren’t overwritten on upgrades. Now that the ‘short_description’ is added to the select statement, you can call it from your template file using your original method.

Hope that helps,
Dan

Thanks Dan! You are the man!! It works beautifully! Thank you very much smile

Best regards,
Mads

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