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

Page 1 of 3
table inside Product Description
 
twentytwo
Jr. Member
 
Total Posts:  6
Joined:  2008-04-23
 

Hi Guys,
My question is; how do I display a formatted table correctly inside the product description attribute?

The steps I’ve taken has been;
1. managed a specific product
2. inside the description field I’ve entered the following code;

<table cellspacing="0" class="data-table" id="product-attribute-specs-table">
  <
tr>
    <
td><h4>Something 1 </h4></td>
  </
tr>
  <
tr>
      <
td>body text </td>
  </
tr>
  <
tr>
      <
td>body text </td>
  </
tr>
  <
tr>
      <
td><h4>something 2</h4></td>
  </
tr>
  <
tr>
      <
td>body text </td>
  </
tr>
  <
tr>
      <
td>body text </td>
  </
tr>
</
table>
As you can see, it’s just a simple table with the default CSS. The problem is that the table shows down the page, and has a lot of white space. I have no idea why this is happening.

I have attached an image of this as well.

Can someone please help?

Cheers,

Image Attachments
2008-05-05_131354.gif
 
Magento Community Magento Community
Magento Community
Magento Community
 
twentytwo
Jr. Member
 
Total Posts:  6
Joined:  2008-04-23
 

Guys,
Can someone please take a quick look into this? I know of other posts that talk of a similar issue.
Just after some kind of work around this for the time being.

Thanks,

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mich81.com
Member
 
Total Posts:  55
Joined:  2008-04-14
 

You have to pay attention to your break line.
Each hyphen is interpreted like a <br>.

Your code should be:
<table cellspacing="0" class="data-table" id="product-attribute-specs-table"><tr><td><h4>Something 1 </h4></td></tr><tr><td>body text </td></tr><tr><td>body text </td> </tr><tr><td><h4>something 2</h4></td></tr><tr><td>body text </td></tr><tr><td>body text </td></tr></table>

 
Magento Community Magento Community
Magento Community
Magento Community
 
TheHuntingDynasty
Jr. Member
 
Total Posts:  25
Joined:  2008-06-27
 

Great solution!

Keywords: tables, product description, spaced out, spaces, layout, html, low, css

 
Magento Community Magento Community
Magento Community
Magento Community
 
balero
Sr. Member
 
Avatar
Total Posts:  170
Joined:  2009-01-29
埼玉県所沢市
 

A general principle to use in troubleshooting this stuff is to peek the HTML in the source to see what Magento is doing.

Mich81.com - 24 May 2008 01:57 AM

You have to pay attention to your break line.
Each hyphen is interpreted like a <br>

You meant “each return” (or “each newline/linefeed or whatever), right?

Is there any reason not to go nuts with formating the product description? Does it appear elsewhere in the interface where the formatting would break things?

 
Magento Community Magento Community
Magento Community
Magento Community
 
beppe77
Jr. Member
 
Total Posts:  2
Joined:  2009-03-04
 


oh oh I’ve solved the problem changing from:
<?php echo $_description ?>
to
<?php echo $_helper->productAttribute($_product, $_product->getDescription(), 'description') ?>

In fact I show the product description as it would be the product short description.

THE CHANGE MUST BE MADE IN FILE: app/design/frontend/default/default/template/catalog/product/view.phtml

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dunester
Jr. Member
 
Total Posts:  13
Joined:  2009-02-27
 
beppe77 - 13 March 2009 06:23 AM


oh oh I’ve solved the problem changing from:
<?php echo $_description ?>
to
<?php echo $_helper->productAttribute($_product, $_product->getDescription(), 'description') ?>

In fact I show the product description as it would be the product short description.

THE CHANGE MUST BE MADE IN FILE: app/design/frontend/default/default/template/catalog/product/view.phtml

Thanks for that - saves a lot of wasted time changing tables to images, which is how I’ve been getting around this poor coding smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Colin Mattson
Jr. Member
 
Total Posts:  14
Joined:  2008-06-11
 

The “right” way to do this is to instead edit catalog/product/view/description.phtml.

Out of the box, the description template contains this code:

<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($this->getProduct()->getDescription()), 'description'?>

The gubbins we don’t want is this part: nl2br(...), which converts new lines (nl) to (2) HTML line breaks (br).

Simply delete the nl2br call from around getDescription and you’re good to go:

<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $this->getProduct()->getDescription(), 'description'?>

Note that the Short Description makes an nl2br call of its own in catalog/product/view.phtml, so you may need to edit that file too if you want to use full HTML formatting in the short description field.

 
Magento Community Magento Community
Magento Community
Magento Community
 
psy
Jr. Member
 
Total Posts:  27
Joined:  2008-12-09
 
beppe77 - 13 March 2009 06:23 AM


oh oh I’ve solved the problem changing from:
<?php echo $_description ?>
to
<?php echo $_helper->productAttribute($_product, $_product->getDescription(), 'description') ?>

In fact I show the product description as it would be the product short description.

THE CHANGE MUST BE MADE IN FILE: app/design/frontend/default/default/template/catalog/product/view.phtml

Fantastic solution.. I am interested however; as a PHP programmer, Magento Noob, your solution works, but makes not sense.  What is the logic you used to come up with your solution?  How did you figure it out?

Regards
psy

 
Magento Community Magento Community
Magento Community
Magento Community
 
davedavedave
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2007-08-31
 
Colin Mattson - 31 March 2009 09:08 AM

The “right” way to do this is to instead edit catalog/product/view/description.phtml.

Out of the box, the description template contains this code:

<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($this->getProduct()->getDescription()), 'description'?>

The gubbins we don’t want is this part: nl2br(...), which converts new lines (nl) to (2) HTML line breaks (br).

Simply delete the nl2br call from around getDescription and you’re good to go:
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $this->getProduct()->getDescription(), 'description'?>

Note that the Short Description makes an nl2br call of its own in catalog/product/view.phtml, so you may need to edit that file too if you want to use full HTML formatting in the short description field.

THANK YOU!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
ckleiman
Jr. Member
 
Total Posts:  3
Joined:  2009-04-20
 
DavePit.com - 05 April 2009 08:30 AM

Colin Mattson - 31 March 2009 09:08 AM
The “right” way to do this is to instead edit catalog/product/view/description.phtml.

Out of the box, the description template contains this code:
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($this->getProduct()->getDescription()), 'description'?>

The gubbins we don’t want is this part: nl2br(...), which converts new lines (nl) to (2) HTML line breaks (br).

Simply delete the nl2br call from around getDescription and you’re good to go:
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $this->getProduct()->getDescription(), 'description'?>

Note that the Short Description makes an nl2br call of its own in catalog/product/view.phtml, so you may need to edit that file too if you want to use full HTML formatting in the short description field.

THANK YOU!!

Don’t delete the ( before $this

Awesome Solution! Many thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
ncp911
Jr. Member
 
Avatar
Total Posts:  5
Joined:  2008-11-16
Florida, USA
 
Colin Mattson - 31 March 2009 09:08 AM

The “right” way to do this is to instead edit catalog/product/view/description.phtml.

Out of the box, the description template contains this code:

<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($this->getProduct()->getDescription()), 'description'?>

The gubbins we don’t want is this part: nl2br(...), which converts new lines (nl) to (2) HTML line breaks (br).

Simply delete the nl2br call from around getDescription and you’re good to go:
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $this->getProduct()->getDescription(), 'description'?>

Note that the Short Description makes an nl2br call of its own in catalog/product/view.phtml, so you may need to edit that file too if you want to use full HTML formatting in the short description field.

You Need to do the same thing in the short description section of the veiw.phtml file.
Original

<?php echo $_helper->productAttribute($_productnl2br($_product->getShortDescription()), 'short_description'?>
should be changed to this.
Fixed
<?php echo $_helper->productAttribute($_product$_product->getShortDescription(), 'short_description'?>
It is the same as the previous fix but in a different location. in about line 88 (for me anyways).
 
Magento Community Magento Community
Magento Community
Magento Community
 
Eric Cavalcanti
Guru
 
Avatar
Total Posts:  710
Joined:  2008-09-28
San Antonio
 

Thanks a lot.
Helped me.
:D

 
Magento Community Magento Community
Magento Community
Magento Community
 
Eric Cavalcanti
Guru
 
Avatar
Total Posts:  710
Joined:  2008-09-28
San Antonio
 

The problem is, now we will have to use everytime a <br/>
I have over 500 products, just 6 have tables… lol, now all are messed.
Need to go over and change back the files. And only edit those products with table, but its a LONG table code, almost 500 lines. lol

 
Magento Community Magento Community
Magento Community
Magento Community
 
tmas73
Jr. Member
 
Total Posts:  24
Joined:  2009-04-23
 

So this changed in Magento 1.4 how would the code be changed now?

<div class="std">
        
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($_description), 'description'?>
    
</div>
 
Magento Community Magento Community
Magento Community
Magento Community
 
leozhang88
Jr. Member
 
Avatar
Total Posts:  10
Joined:  2009-09-29
 

same problem i had, don’t know how to change the code in 1.4??

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 3