product.html.twig:如何显示在树枝模板控制器阵列
<ul id="navigation">
<li>
<a href="<?php echo product.getId() ?>">
<?php echo product.getDescription() ?>
</a>
</li>
</ul>
控制器的操作方法包括:
public function showAction($id = 5)
{
$product = $this->getDoctrine()
->getRepository('AppBundle:Product')
->find($id);
if (!$product) {
throw $this->createNotFoundException(
'No product found for id '.$id
);
}
else
{
return $this->render('default/productItem.html.twig', array(
'id'=> $id,
'name' => $name));
}
}
我不能在列表中看到
难道是持有对象的数组? '$ product'是一个对象吗? –
为什么不用'href =“{{product.id}}”' – Matteo