- Hits: 989
- 2 Comments
- Subscribe to updates
- Bookmark
Removing line breaks or soft returns in Virtuemart reviews
It was clear that the line breaks were not coming from a poorly formatted review, as I checked out the entry in the database to ensure there were no line breaks present - and there weren't!
Therefore, it had to be coming from the Virtuemart code trying to be 'helpful'!
Virtuemart has a slightly peculiar way of templating and styling, so it's often a bit of a chore to track down what is actually styling particular areas of the store. Eventually I managed to track down the offending code to a file called reviews.tpl.php in the following directory
components>com_virtuemart>themes>YOURTHEME>templates>common
YOURTHEME is usually 'default' unless you've set up your own theme for Virtuemart.
Look for the line
<blockquote><div><?php echo wordwrap($review['comment'], 150, "<br/>\n", true ); ?></div></blockquote>
You will notice that this is trying to insert a linebreak within the review after 150 characters - perhaps useful if your sentence ends there, but not terribly helpful if this falls mid-sentence as many of mine did! You can remove the section which refers to the line break and it will stop inserting these tags:
<blockquote><div><?php echo wordwrap($review['comment'] ); ?></div></blockquote>
Hope this helps!
Comments
Thanks for taking the time to comment Troy, and it seems that lots of other people have had the same problem as you. Here is a response I found on the VM forums which might help:
http://forum.virtuemart.net/index.php?PHPSESSID=dcee030c319b14129f40c624f39ff2c4&topic=63394.0
You're right it is not the nl2br issue, it is more a permission issue.
Therefore go to /components/com_virtuemart/virtuemart_parser.php
in line 165 you may find (after //prevent SQL injection) this codeline
Code:
if ($perm->check('admin,storeadmin')) {
just add shopper and it may work
Code:
if ($perm->check('admin,storeadmin,shopper')) {
I hope this helps, I'll write an article on it as well!
Ruth

This is kind of helpful, thank you. I was wondering the same thing about my site and you're right, it does fix that issue. I have a related one, though that this doesn't address.
If the reviewer does insert a return into their review, which it seems most all of them do, it doesn't accept it, but it does input this "rnrn" into the sentence where the return was. I've been going into the database and removing the characters, but any ideas what a php solution to that would be?
Thanks for your first post and for any ideas you have on this as well.