I have a MySQL database with some content created with ckeditor. The text is stored like this <p><strong>L&rsquo;automatisation des syst&egrave;mes dans le monde so with HTML entities.
With Twig, in a Symfony project, when I want to display my data, I use for this field {{ article.mytext|raw}} but it display <p><strong>L’automatisation des systèmes dans le monde so it's not fully decoded and interpreted...
With PHP I have no problem and a html_entity_decode($mytext); do the job perfectly.
Can you help me ? What is wrong ?
As requested, more of the code :
in MySQL in a utf8_general_ci column "vTexte"
<p><strong>L&rsquo;automatisation des syst&egrave;mes dans le monde
in my controler in symfony :
namespace MU\CoreBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use MU\CoreBundle\Entity\Veille;
class CoreController extends Controller
{
public function actufreeAction()
{
$repository = $this
->getDoctrine()
->getManager()
->getRepository('MUCoreBundle:Veille')
;
$listactufree = $repository->findBy(
array('vStatus' => '4'), // Critere
array('vDatePublished' => 'desc'), // Tri
5, // Limite
0 // Offset
);
$content = $this->get('templating')->render('MUCoreBundle::news.html.twig', array(
'listactufree' => $listactufree,
));
return new Response($content);
}
}
In my Twig file news.html.twig
{% for veille in listactufree %}
{{ veille.vTexte | raw }}
{% endfor %}
With that, it show :
<p><strong>L’automatisation des systèmes dans le monde
and I want :
L’automatisation des systèmes dans le monde
html_entity_encodesomewhere before sending it to the DB?htmlspecialcharsbefore the insertion but I already tried without it and it change nothing.html_entity_decodebefore the insertion, but I used one to display this HTML data from my DB and it's work. Without thehtml_entity_decodeis show the result I have in Symfony after using the raw filter<p><strong>L’automatisation des systèmes dans le mondeit's why I was trying previouly to use 2 times the raw filter...p><strong>L’automatisation des systèmes dans le mondeand when I use the raw filter on this, it works. It's why i was confused and tried to use the raw filter 2 times.