php - Outputting HTML In Twig From Database -


i have database stores text html inside of varchar column. looks this:

click here go site: <a href="http://www.google.com">http://www.google.com</a>. 

however when output html page appears plain text , not clickable link.

how make output valid html tag , create clickable href?

i fetch data using slim route:

$app->get('/projects/:id', function($id) use ($app) {     // open dataabse connection     $con = connect_db();     // query projects specific id     $project = $con->query("select * projects projectid=".$id."")->fetch(pdo::fetch_obj);     // documents associated project id     $documents = $con->query("select * projectdocuments projectid=".$id."")->fetchall(pdo::fetch_obj);     // student updates project id     $updates = $con->query("select * studentupdates left join asapers on asapers.userid = studentupdates.userid          projectid=".$id." order studentupdates.date desc limit 5")->fetchall(pdo::fetch_obj);      $projectarray = array();      foreach ($project $key => $value) {         $project->{$key} = htmlspecialchars_decode($value);         array_push($projectarray, $project->{$key});     }      print_r($projectarray);      // render single project page     $app->render('single.project.twig', array('project'=>$projectarray, 'updates'=>$updates, 'documents'=>$documents)); }); 

inside single.project.twig

<h2>{{ project[1] }}</h2> <p>{{ project[2] }}</p> 

if print array out in php appears html link! however, print out variable using twig appears plain text again!

just figured out. sees here answer.

<h2>{{ project[1] | raw }}</h2> <p>{{ project[2] | raw }}</p> 

adding | raw output html html.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -