Topic-icon Can't have Enter in my description

Active Subscriptions:

None
10 years 4 months ago #39867 by pastre
Hello there,
I use this in a php template :

<?php
		$mdesc = htmlentities(strip_tags($this->element->product_description), ENT_QUOTES, 'UTF-8');
		$mdesc =trim(str_replace('&nbsp;', ' ', $mdesc));

?>
			
{SCOpenGraph description=<?php echo $mdesc;?>}

All is ok. I see my description with special chars in Facebook.
But, at once I press ENTER somewhere in my product description, it stops to work. The default description come back.


An idea???


Joomla 3.2.1
JFBConnect 5.2.2
The topic has been locked.
Support Specialist
10 years 4 months ago #39869 by alzander
Hmm.. Not sure. Can you post (or Private Message) a link to a page where you are using an Enter in the description so we can see what's happening?

You may be able to do the following, which will strip all new line characters, since you really shouldn't use them in the description if possible:
{SCOpenGraph description=<?php echo str_replace(array("\r\n", "\n\r", "\r", "\n", "", $mdesc); ?>}

I hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
10 years 4 months ago #39873 by pastre
It works now! Thanks.

Are you saying that I shouldn't use multi-line description? Can you please explain a little?
The topic has been locked.
Support Specialist
10 years 4 months ago #39879 by alzander
To my knowledge, multi-ling Open Graph descriptions don't work. Facebook (I'm pretty sure) will remove extra carriage returns from your description before it's used as the description area. Additionally, using a carriage return will decrease the total amount of words you can use since there's only a limited area that the 'intro' to your post can be displayed in a Facebook news feed.

I hope that helps explain. If you really want/need carriage returns, let me know. We can investigate it further if necessary.

Thanks,
Alex
The topic has been locked.