doubingjiu3199 2014-06-29 14:11
浏览 61

Symfony2和Smarty3 - 如何从Doctrine中获取模板中常见元素的数据?

I just got into developing with the Symfony2 framework and I really like it so far - I use the Smarty3 Templating Engine as I already worked with it before, and I am now starting to get into Doctrine for fetching data from a Database.

My question is more a structural one - lets say, I want a navigation / menu on every page that contains elements that are fetched from Doctrine (and not hard coded into the template) - I know, how to use Smarty's "include" and "extends" tags to build up some inheritance, but how would I get the data for the menu?

Lets say, I've got a controller called "detailAction" that passes an array with a description, a title, etc. to a Smarty template - that part of course works like a charm. But where/when exactly would I fetch the data for the menu / the footer / everything that is "shared" on multiple pages? I know I can't put that query into the "detailAction" but rather in something like an "indexAction" - but how would I then connect both the detail template and the index template, as I can only call the "render()" function once?

I really hope this makes sense - can the "forward()" function of Symfony2 help me with this?

Thanks for your help!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 Unity接入微信SDK 无法开启摄像头
    • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算
    • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
    • ¥20 有人知道这种图怎么画吗?
    • ¥15 pyqt6如何引用qrc文件加载里面的的资源