VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: chrlar on April 09, 2013, 15:45:27 PM

Title: Must use <br> for line break in short description
Post by: chrlar on April 09, 2013, 15:45:27 PM
Updated:
We are using Joomla 2.5.9
VM 2.0.20b

-----

If we use " in our text in a product's short description field, it kind of fails. Or that is, at the end of a paragraph:
Rally asfaltdekk i 15"<br>Kommer i flere størrelser, og i soft, medium & hard.

We have to use line break, or it doesn't make a new line.

If we use two ' it works.
Rally asfaltdekk i 15''<br>Kommer i flere størrelser, og i soft, medium & hard.

The text after the " and half the tag is displayed all the way on top of the page.
(See image)
(The text is almost the same as the background, so I have highlighted it.)

It is possible to use two of the ' characters, but since we're not the only administrators of the VM store, we would prefer it if we could also use the " character.
Because we sell tyres and rims, and their size descriptions are in inches.

What is easier; to allow quotes and tag, or to automatically make a line break like in the long description field...?

:)

This code is in the administrator/components/com_virtuemart/views/product/tmpl/product_edit_description.php


<fieldset>
<legend><?php echo JText::_('COM_VIRTUEMART_PRODUCT_FORM_S_DESC'?></legend>
<textarea class="inputbox" name="product_s_desc" id="product_s_desc" cols="65" rows="3" >
<?php echo $this->product->product_s_desc?></textarea>
</fieldset>

<fieldset>
<legend><?php echo JText::_('COM_VIRTUEMART_PRODUCT_FORM_DESCRIPTION'?></legend>
<?php echo $this->editor->display('product_desc'$this->product->product_desc'100%;''550''75''20', array('pagebreak''readmore') ) ; ?>
</fieldset>


Would it help if the editor was used for the short description field as well? Then it would save the line breaks as HTML and < br >?

:)

[attachment cleanup by admin]
Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 10, 2013, 13:53:18 PM
The problem is actually in category view. Because in product detail view, the short description is not displayed.
But too much fuss about the code in the s_desc field (back end) messes up the html in the product detail view.

(I use two ' instead of " .)

[attachment cleanup by admin]
Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 10, 2013, 13:57:14 PM
So the fact remains, we need to use a <br> in order for the lines to break in category view.

So this: (s_desc form field)
This is to be on the first line.
And this it to be on the second line, as a new line.


turns to this: (category view)
This is to be on the first line. And this it to be on the second line, as a new line.

And then using <br>: (s_desc form field)
This is to be on the first line. <br>
And this it to be on the second line, as a new line.


turns to this: (category view)
This is to be on the first line.
And this it to be on the second line, as a new line.


All I'm saying is that it would be nice to get a line break without having to write <br>.

:)
Title: Re: Must use <br> for line break in short description
Post by: Milbo on April 10, 2013, 17:53:55 PM
hmm, lol interesting.

Which editor do oyu use? I think the editor is responsible for this.
Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 10, 2013, 18:37:16 PM
Which editor? Hmmm.

For Joomla I always use Firefox... (IE doesn't work with Joomla)
And in Joomla we use the TinyMCE, but there is no editor in use for the s_desc field (backend)...

:)
Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 10, 2013, 19:14:33 PM
Is it possible to use an editor for the product_s_desc form as well as the product_desc form?

To change this
<textarea class="inputbox" name="product_s_desc" id="product_s_desc" cols="65" rows="3" >
<?php echo $this->product->product_s_desc?></textarea>


to

<?php echo $this->editor->display('product_s_desc'$this->product->product_s_desc'100%;''250''75''20', array('pagebreak''readmore') ) ; ?>

to make it like product_desc form:
<fieldset>
<legend><?php echo JText::_('COM_VIRTUEMART_PRODUCT_FORM_DESCRIPTION'?></legend>
<?php echo $this->editor->display('product_desc'$this->product->product_desc'100%;''550''75''20', array('pagebreak''readmore') ) ; ?>
</fieldset>


:)
Title: Re: Must use <br> for line break in short description
Post by: Milbo on April 10, 2013, 21:03:38 PM
No, I mean which joomla editor, TinyMC, or JCE?
Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 10, 2013, 21:35:02 PM
As I wrote three posts ago:
... And in Joomla we use the TinyMCE, but there is no editor in use for the s_desc field (backend)...

;)
Title: Re: Must use <br> for line break in short description
Post by: PRO on April 10, 2013, 22:20:07 PM
just write a little function and use "codes"

Like i did here
http://forum.virtuemart.net/index.php?topic=109549.0

Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 10, 2013, 22:37:59 PM
Maybe I'm a little slow in this area... But I don't see how that helps me? :-\

All I need is the line break in the category view if/when I make a line break in the s_desc form field backend...

:)
Title: Re: Must use <br> for line break in short description
Post by: PRO on April 10, 2013, 23:35:15 PM
Quote from: chrlar on April 10, 2013, 22:37:59 PM
Maybe I'm a little slow in this area... But I don't see how that helps me? :-\

All I need is the line break in the category view if/when I make a line break in the s_desc form field backend...

:)

here is something someone did with 1.1
https://forum.virtuemart.net/index.php?topic=72519.msg241758#msg241758


You could do the same with a   > etc.

Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 10, 2013, 23:44:08 PM
But doesn't this mean that for every . (punctuation mark) there will be a line break?
<?php $product_s_desc str_replace'.''.<br />'$product_s_desc ); ?>

We have over 10000 products, so it's a bit risky making that change, since we may risk that there will be line breaks where we don't want line breaks... ?
:-\

But thanks for trying to help.. :)
Title: Re: Must use <br> for line break in short description
Post by: PRO on April 11, 2013, 03:07:10 AM
Quote from: PRO on April 10, 2013, 22:20:07 PM
just write a little function and use "codes"

Like i did here
http://forum.virtuemart.net/index.php?topic=109549.0



thats why I said use CODES


Like  >=<br>

<?php $product->product_s_desc = str_replace( '>', '<br />', $product->product_s_desc ); ?>
       <?php echo $product->product_s_desc; ?>



short desc

blah,blah,blach>more blah,blah,blah

shows

Blah,blah,blah
more blah,blah,blah

Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 11, 2013, 09:49:13 AM
I think I'm looking for something with the code "nl2br();", but I'm not quite sure how to use it. Or if it will work at all, if the text in the database is all in one long text string. Since s_desc form field is a non-editor textarea.

That's why I was thinking about making the non-editor textarea into an editor textarea, like the one for the long description.

Either way, is this someting to think about for the developers? :)
Title: Re: Must use <br> for line break in short description
Post by: PRO on April 11, 2013, 11:58:15 AM
http://forum.virtuemart.net/index.php?topic=91396.0


dont know if it works
Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 11, 2013, 14:51:27 PM
So, I did it! :)

In administrator/components/com_virtuemart/views/product/tmpl/product_edit_description.php  (line#21)
I changed:

<fieldset>
<legend><?php echo JText::_('COM_VIRTUEMART_PRODUCT_FORM_S_DESC'?></legend>
<textarea class="inputbox" name="product_s_desc" id="product_s_desc" cols="65" rows="3" >
<?php echo $this->product->product_s_desc?></textarea>
</fieldset>


to

<fieldset>
<legend><?php echo JText::_('COM_VIRTUEMART_PRODUCT_FORM_S_DESC'?></legend>
<?php echo $this->editor->display('product_s_desc'$this->product->product_s_desc,
  
'100%;''250''75''20', array('pagebreak''readmore') ) ; ?>

</fieldset>


I did nothing to the tables in the database.

And it seems to work! :)

Although I still can't use " in the text... so I use two ' instead.
(When I look at the html source of the text, it "translates a & to &amp; but not " to &quote;.)(Did that make sense?)

:)

[attachment cleanup by admin]
Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 11, 2013, 20:21:13 PM
Well, it works....

But...

If I make a change in the SHORT description field --- then save ---- everything is normal.

If I make a change in the LONG description field --- then save ---- I get this pop up message...

( I click on leave page, and it saves...)

Maybe my new text field code should be different somehow?

<?php echo $this->editor->display('product_s_desc', $this->product->product_s_desc,
  '100%;', '250', '75', '20', array('pagebreak', 'readmore') ) ; ?>

I'm not sure of all "content" in the tag... like array...pagebreak...readmore... what does that mean...? Can I remove it?

:)

[attachment cleanup by admin]
Title: Re: Must use <br> for line break in short description
Post by: jjk on April 11, 2013, 22:11:12 PM
Hi, I just noticed this forum thread and made a quick test on one of my local Joomla 2.5.9/VM2.0.20b installations. I have no problem adding double quotes (") in the the short description and if the short description text is long, it automaticaly wraps to the next line. I didn't test if this is a problem with the TinyMCE editor, but using the JCE Editor it works. (Note, that every editor plugin has some advantages and disadvantages).
BTW - the length of the short description can be adjusted in ...\components\com_virtuemart\views\category\tmpl\default.php, approximately line 268, which is:
<?php echo shopFunctionsF::limitStringByWord ($product->product_s_desc40'...'?>
If you adjust this file, you can make a copy of this file, give it a different name and save it in the same folder. Afterwards VM offers it automatically as a selectable option in the category browse page dropdown list. This way it doesn't become overwritten when you update VM.

Category screenshot with " in the short descripton attached below.

If it doesn't work for you, maybe your Joomla template uses a different category browse page template.

[attachment cleanup by admin]
Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 11, 2013, 22:26:02 PM
Hmmm... Do you think this has to do with the hosting server...? Linux or Windows? What is better?

We are currently on a Linux server with an old php version. So we have asked to be moved to a new server with the newest php version and Linux.

And privately we have a Windows server (with updated php version) for testing...

Does this have anything to say...?
Title: Re: Must use <br> for line break in short description
Post by: jjk on April 11, 2013, 22:45:35 PM
No, I don't think your problem is related to an old php version. My live shop runs on Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny16 with Suhosin-Patch... and for testing I still use an old version of http://www.apachefriends.org/de/xampp.html (http://www.apachefriends.org/de/xampp.html) running on my old Windows XP PC. (Concerning the choice of Linux/Windows server, I personally would expect fewer problems using a linux server)

Did you ever test your site with one of the Joomla default templates or another simple template?
Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 11, 2013, 22:50:44 PM
I didn't test my site with a Joomla standard template, someone else did...
See this link: http://www.flexiblewebdesign.com/index.php?option=com_kunena&view=topic&catid=5&id=888&Itemid=234

He tested on his server and had the same problem... :-/

I asked him, too, because we use his VM template. :)
Title: Re: Must use <br> for line break in short description
Post by: jjk on April 11, 2013, 23:01:12 PM
I wonder if the template providers's own category browse template was still selected in VM configuration when he tested a different template...  ;)
Title: Re: Must use <br> for line break in short description
Post by: chrlar on April 12, 2013, 14:36:30 PM
See, now I'm really confused.... :-/

I have a Windows test server...
I set Beez 5 as default template.
And only VM own standard files (no external template)

And then, in CATEGORY view, the text is fine with double quotes (") and html (<br>).

I checked out the files
\components\com_virtuemart\views\category\tmpl\default.php
and
\templates\allrounder-j1.6\html\com_virtuemart\category\flexv2list.php

and  the code for product_s_desc is exactly the same in both files:

<?php // Product Short Description
if(!empty($product->product_s_desc)) { ?>
<p class="product_s_desc">
<?php echo shopFunctionsF::limitStringByWord($product->product_s_desc, 120, '...') ?>
</p>
<?php } ?>


So for my template provider's problem, now I noticed his error came up when in product detail view, not category view... Hmmmm..

So I guess we have to overlook this little bug of ours....

We'll keep writing <br> for linebreaks and using two single quotes for double quote.

But thanks for getting involved! :)


:-)