Virya Technologies Blogs

Blogs from Virya Technologies staff

Posted by Ruth Cheesley
Ruth Cheesley
I am the owner and Director of Virya Technologies, with the responsibility for leading the website design team...
User is currently offline
on Wednesday, 10 November 2010
in Joomla! Content Management System

Removing line breaks or soft returns in Virtuemart reviews

After spending quite a while trying to figure out why Virtuemart reviews on a client's site were having line breaks/soft returns inserted apparently at random, I managed to track down the code that was responsible.

virtuemartIt 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!

Rate this blog entry
0 votes
I am the owner and Director of Virya Technologies, with the responsibility for leading the website design team.

I am primarily involved with the day to day management of our website projects, ongoing support contracts and liaising with our clients from across the world.
Trackback URL for this blog entry

Comments

Guest
Troy Kendrick Monday, 28 March 2011

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.

Ruth Cheesley
Ruth Cheesley
I am the owner and Director of Virya Technologies, with the responsibility for leading the website design team...
User is currently offline
Ruth Cheesley Wednesday, 25 May 2011

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

Leave your comment

Guest
Guest Tuesday, 22 May 2012

Looking for our open source software?

viryasoftwarelogo

We release and support our open source software at Virya Software

Find us on

facebook    linkedin    twitter     youtube    vimeo    ViryaTechnologiesJoomlaResources    ViryaTechnologiesonTechnorati    rss

Virya Technologies Newsletter

Receive all the latest tips, news and reviews from Virya Technologies.

Come and meet us!

JUN
01

01.06.2012 07:30 - 09:30
Ipswich Connected Business Breakfast

JUN
01

01.06.2012 12:00 - 17:20
Ecademy BlackStar First Friday Working Lunch

JUN
14

14.06.2012 19:30 - 22:00
Joomla! User Group Suffolk Meeting

JUL
06

06.07.2012 07:30 - 09:30
Ipswich Connected Business Breakfast

JUL
06

06.07.2012 12:00 - 17:20
Ecademy BlackStar First Friday Working Lunch

The latest from Virya Technologies

Virya Technologies After an awesome #jab12 event we are offering 20% discount on all extensions until 7th June - use JAB12 coupon code at http://t.co/XrDJFRbq
Monday, 21 May 2012 07:46
twitter Follow Viryatech on Twitter