I want to store my template text in a databse table.
Name | Text | .....
----------------------------------------------------
Title | My very own Blog | ......
Intro | Hello stranger, this is my blog |
Each item is a record and I want to access each item directly in Twig.
Currently my code is:
public function indexAction()
{
$ObjArr=$EntityManager->getRepository('myBundle:tplitems')->findAll();
foreach($ObjArr as $obj) {
$tplitems[$obj-getName()]=$obj;
}
return $this->render('myBundle::index.html.twig',array('tplitems'=>$tplitems,))
}
which lets me write in Twig:
{{ tplitems.title.text }}
Is there a better/cleaner way to do this ?