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

Extra line spacing in product description! Ahhh! 
 
webmaster18
Jr. Member
 
Total Posts:  23
Joined:  2011-03-11
 

This is beginning to drive me crazy!!!! S0omething that is usually SO SIMPLE is not here… as you could see on:

http://kellyhayesbeta.com/kh2/index.php/unistrut-90-degree-fitting-30.html

There is extra spacing in my product descriptions, but meanwhile in the backend everything is perfect looking…

Anyone else have this issue, any help please...would be very appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiefair
Mentor
 
Avatar
Total Posts:  1848
Joined:  2009-06-04
 

The description field uses the NL2BR function which converts newlines to <br /> tags. So when you put an empty line between paragraphs, you have two linebreaks which doubles the spacing. If you intend on using the WYSIWYG editor, you can modify the template so it works with standard html.

If you’d prefer to keep this a text field with NL2BR, then you let everything wrap, except at the ends of lines and whole paragraphs. You will not see space between the lines and paragraphs until it is viewed in the front end.

NL2BR is especially hellacious if you try to use lists and tables in the description field. You must enter each item as a complete, unbroken string from start tag to end tag so there are no newlines to be converted.

The following code snippet is a way of offering dual mode descriptions (text or html), it will need to be modified to fit in with the actual template code, but the idea is to have a yes/no attribute next to the description entry field named something like Is HTML? and this attribute is consulted to just display the HTML or to pass text through the NL2BR processor:

<?php if ($_product->getIsHtml() == 1): ?>
     <?php 
echo $_description ?>
<?php 
else: ?>
     <?php 
echo nl2br($_description?>
<?php 
endif; ?>

Because you tried to put in a table and a list, the html output from NL2BR is as follows with all those <br> tags at the top coming from each and every newline in your table:

<div style="" id="product_tabs_description_tabbed_contents"><div class="box-collateral box-description">
    <
div class="std">
        <
br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><table border="0" cellpadding="0" cellspacing="0" height="222" width="714">

    <
tbody>
        <
tr>
            <
td height="19"><br>
            <
div style="padding: 5px; margin: 0px;"><strong>UNISTRUTP1346GR 3 Hole90° Fitting Perma-Green III (GR)</strong></div><br>
            </
td>
        </
tr>
        <
tr>
            <
td height="22">&nbsp;</td>

        </
tr>
        <
tr>
            <
td height="19"><span style="color: rgb(0, 0, 0);"><strong>Standard Dimensions:</strong></span></td>
        </
tr>
        <
tr>
            <
td height="19">&nbsp;</td>
        </
tr>
        <
tr>

            <
td height="95"><br>
            <
ul><br>
                <
li><span style="color: rgb(0, 0, 0);">Hole Diameter9/16" (14mm)</span></li><br>
                <li><span style="
colorrgb(000);">Hole Spacing (From End): 13/16" (21mm)</span></li><br>
                <
li><span style="color: rgb(0, 0, 0);">Hole Spacing (On Center): 1-7/8" (48mm)</span></li><br>
                <li><span style="
colorrgb(000);">Width: 1-5/8" (41mm)</span></li><br>
                <
li><span style="color: rgb(0, 0, 0);">Thickness1/4" (6mm)</span></li><br>

            </ul><br>
            </td>
        </tr>
        <tr>
            <td height="
19">&nbsp;</td>
        </tr>
        <tr>
            <td><br>
            <p><span style="
colorrgb(000);">The performance of Unistrut’s Perma-Green III far exceeds that of      conventional finishes. And compared to competitive â€œhigh-performance”      coatings, Perma-Green III provides superior resistance to chalking,      checking and fading and is far less vulnerable to common acidic      atmospheres, solvents and alkalis. Just as important, Perma-Green III is      the result of an environmentally neutral process that virtually      eliminates the toxic metals commonly found in competitive paint-based      finishes.</span></p><br>

            <p><span style="
colorrgb(000);">Unistrut Perma-Green III is a factory applied, electro-deposition      acrylic coating with superior rust protection and fade-resistance. The      acrylic coating is a proprietary formulation and is essentially      â€œheavy-metal” free. The electrodeposition coating process provides a      smooth, hard, durable surface which is completely cured. This inhibits      introduction of airborne contaminates which can adversely affect      sensitive manufacturing environments.</span><br><br>
            <br><br>
            <span style="
colorrgb(000);"> Before the     electrodeposition acrylic coating is applied, Unistrut  channel is     thoroughly cleaned and coated with a zinc phosphate  conversion coating.     Unistrut’s unique, custom-designed â€œprep” process  consists of ten     separate steps, the most thorough in the industry. The  cleaning,     phosphating and electrodeposition coating processes are  continuous and,     unlike â€œbatch” processing, result in a uniform quality  coating.</span><br><br>
            <br><br>
            <span style="
colorrgb(000);"> Production samples are tested on a continuous basis for corrosion      resistance. Unistrut Perma-Green III exceeds 400 hours salt spray (1/8"      creep from scribewhen tested to ASTM B117Unscribed samples exceed      600 hours salt spray. (6red rust)</span></p><br>
            </
td>

        </
tr>
    </
tbody>
</
table>    </div>
</
div>
</
div>
 
Magento Community Magento Community
Magento Community
Magento Community
 
webmaster18
Jr. Member
 
Total Posts:  23
Joined:  2011-03-11
 

Thank you for the reply...I see what you are saying. But how would I go about fixing this...see I am going to be adding possibly almost 100k products and would like to have this process as simple as possible - as it should be.

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiefair
Mentor
 
Avatar
Total Posts:  1848
Joined:  2009-06-04
 

Well, there’s no time like the present.

If you’re just beginning and don’t have more than test product in your Magento installation; and are planning on having HTML in the description attribute and also on having the WYSIWYG editor be a primary function, then you modify the template by removing the NL2BR function all-together. Believe me, this would have been my choice before entering 9500 items

In 1.4.x.x, the description is displayed by a code block like the following:

<?php $_description $this->getProduct()->getDescription(); ?>
<?php 
if ($_description): ?>
    
<h2><?php echo $this->__('Details'?></h2>
    <
div class="std">
        
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($_description), 'description'?>
    
</div>
<?php endif; ?>

Ditch nl2br as follows:

<?php $_description $this->getProduct()->getDescription(); ?>
<?php 
if ($_description): ?>
    
<h2><?php echo $this->__('Details'?></h2>
    <
div class="std">
        
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description'description'?>
    
</div>
<?php endif; ?>

Code switch attribute so you can run both side by side until you’ve HTMLized all your descriptions:

<?php $_description $this->getProduct()->getDescription(); ?>
<?php 
if ($_description): ?>
    
<h2><?php echo $this->__('Details'?></h2>
    <
div class="std">
    
<?php if ($_product->getIsHtml() == 1): ?>
        <?php 
echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description'description'?>
     <?php 
else: ?>
        <?php 
echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($_description), 'description'?>
    <?php 
endif; ?>
    
</div>
<?php endif; ?>

Short description also uses NL2BR…

 
Magento Community Magento Community
Magento Community
Magento Community
 
webmaster18
Jr. Member
 
Total Posts:  23
Joined:  2011-03-11
 

@chiefair, thank you so much for your help so far…

I am using 1.5...what files would I edit though in order to make these changes.

 
Magento Community Magento Community
Magento Community
Magento Community
 
chiefair
Mentor
 
Avatar
Total Posts:  1848
Joined:  2009-06-04
 

To start figuring that out, since it looks like you’re using a custom template, is to go into system config -> developer -> debug at your storefront level (dropdown box up on the left) and turn on path hinting. Then when you go into the front end, it should tell you which files are producing the particular html block you want to edit. Follow the path given in your custom template directory and it will be in the folder or one of the subfolders in that path hint.

Keep a backup copy of the file you edit. Upload the template file and clear the cache to view the change.

 
Magento Community Magento Community
Magento Community
Magento Community
 
webmaster18
Jr. Member
 
Total Posts:  23
Joined:  2011-03-11
 

Thanks again! I will let you know how it goes...I do know though, that when I tried to turn on the hints for the frontend before it did not work but only liked to work on the admin end for some reason…

and yes, I am using Hellowired template.

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