Forums / Templates, Stylesheets, Page Layout / Trying to add line breaks into description

Trying to add line breaks into description

Views: 3,572

Results 1 to 14 of 14
22 Apr 2008, 7:55 PM
#1
dougware avatar

dougware

New Zenner

Join Date:
Mar 2008
Posts:
13
Plugin Contributions:
0

Trying to add line breaks into description

I'm attempting to add line breaks into the product listing.

As you can see below, the word 'Test" is on the same line for the first product.

http://store.freehandnetworks.com/index.php?main_page=index&cPath=5_9

I commented out the lines in functions_general.php that changes the "<BR>" type tags to spaces. It appears the tags are still being changed to spaces.

Does anyone have any pointers to keep the tags from being replaced?

Thanks,
Doug

22 Apr 2008, 8:11 PM
#2
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,185
Plugin Contributions:
0

Re: Trying to add line breaks into description

DougWare:

I'm attempting to add line breaks into the product listing.

As you can see below, the word 'Test" is on the same line for the first product.

http://store.freehandnetworks.com/index.php?main_page=index&cPath=5_9

I commented out the lines in functions_general.php that changes the "<BR>" type tags to spaces. It appears the tags are still being changed to spaces.

Does anyone have any pointers to keep the tags from being replaced?

Thanks,
Doug

for up to 10 users and 1 month management service. <br />Test

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.

Zen Cart Certified hosting at myZenCartHost.com.

22 Apr 2008, 8:32 PM
#3
dougware avatar

dougware

New Zenner

Join Date:
Mar 2008
Posts:
13
Plugin Contributions:
0

Re: Trying to add line breaks into description

haredo:

for up to 10 users and 1 month management service. <br />Test

That produced the same result...

23 Apr 2008, 6:27 PM
#4
dougware avatar

dougware

New Zenner

Join Date:
Mar 2008
Posts:
13
Plugin Contributions:
0

Re: Trying to add line breaks into description

What's even stranger is that the <P> tag works, just not the <BR> tag. I've searched and searched, and I don't seem to be able to find where the tag is being replaced.

Can someone please point me in the right direction?

Thanks,
Doug

23 Apr 2008, 7:56 PM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Trying to add line breaks into description

The place to change this is not in functions_general.php, but in /includes/modules/your_template/product_listing.php.

All you need to do is comment out zen_clean_html in two places, like this:

/zen_clean_html/```php
case 'PRODUCT_LIST_NAME':
$lc_align = '';
if (isset($_GET['manufacturers_id'])) {
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(/zen_clean_html/(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
} else {
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(/zen_clean_html/(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
}
break;

23 Apr 2008, 8:44 PM
#6
dougware avatar

dougware

New Zenner

Join Date:
Mar 2008
Posts:
13
Plugin Contributions:
0

Re: Trying to add line breaks into description

That worked perfectly!

Thanks!

gjh42:

The place to change this is not in functions_general.php, but in /includes/modules/your_template/product_listing.php.

All you need to do is comment out zen_clean_html in two places, like this:

/zen_clean_html/```php
case 'PRODUCT_LIST_NAME':
$lc_align = '';
if (isset($_GET['manufacturers_id'])) {
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(/zen_clean_html/(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
} else {
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(/zen_clean_html/(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
}
break;

23 Apr 2008, 8:51 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Trying to add line breaks into description

You do need to be aware that if your description is longer that the length set in admin > Configuration > Product Listing, you risk having HTML tags cut off which can cause errors on your page. It is best to set the limit to longer than the longest description you expect to have; or you can take care not to have any HTML tags at all beyond that limit.

2 Feb 2009, 5:21 PM
#8
semaxd avatar

semaxd

New Zenner

Join Date:
May 2008
Location:
Ventura Co.
Posts:
82
Plugin Contributions:
1

Re: Trying to add line breaks into description

excellent this helped!!

13 Jun 2011, 11:47 PM
#9
tamalita avatar

tamalita

New Zenner

Join Date:
Jan 2006
Posts:
57
Plugin Contributions:
0

Re: Trying to add line breaks into description

awesome!! thanks for this info!!

1 Mar 2012, 4:49 PM
#10
skrillnet avatar

skrillnet

New Zenner

Join Date:
May 2010
Location:
Arkansas
Posts:
33
Plugin Contributions:
0

Re: Trying to add line breaks into description

I know this is digging up an old thread, but is it possible to have it detect the tags that were opened and not closed in the truncated version, and insert closing tags if needed at the end of the shortened text?

3 Mar 2012, 5:11 PM
#12
bimo_in_bali avatar

bimo_in_bali

New Zenner

Join Date:
Jan 2009
Location:
Earth
Posts:
36
Plugin Contributions:
0

Re: Trying to add line breaks into description

Hello Everyone,
I need some help re html for product description.
I created columns in html, the columns shows all right in admin preview (when inserting new product), but the columns are missing in live shop.
Please see attached images to see what i mean.

Thank you previously for any help :smile:
[IMG]http://img405.imageshack.us/img405/4124/htmlcolumns.jpg[/IMG]

6 Mar 2012, 7:24 PM
#13
skrillnet avatar

skrillnet

New Zenner

Join Date:
May 2010
Location:
Arkansas
Posts:
33
Plugin Contributions:
0

Re: Trying to add line breaks into description

Actually, this turned out really easy. PHP 5 has html Tidy already compiled with it by default, so I just put that into a var, ran Tidy, and there you go. No problems at all to this point. Here is an example of the code.

        case 'PRODUCT_LIST_MODEL':
        $lc_align = '';
        $lc_text = $listing->fields['products_model'];
        break;
        case 'PRODUCT_LIST_NAME':
        $lc_align = '';
        if (isset($_GET['manufacturers_id'])) {
		
		//processing description to allow it to display html tags in the product listing section.
		//this is to process the text so that there are no tags left that are not closed.
		$description_text_processed = '<div class="listingDescription">' . zen_trunc_string(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id'])), PRODUCT_LIST_DESCRIPTION) . '</div>';
		
		$tidy = new Tidy();
		$clean = $tidy->repairString($description_text_processed, array(
			'output-xml' => true,
			'input-xml' => true
		));
		
          $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3>' . $clean ;
        } else {
		$description_text_processed = '<div class="listingDescription">' . zen_trunc_string(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id'])), PRODUCT_LIST_DESCRIPTION) . '</div>';
		
		$tidy = new Tidy();
		$clean = $tidy->repairString($description_text_processed, array(
			'output-xml' => true,
			'input-xml' => true
		));

          $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3>' . $clean;
        }
        break;