简体   繁体   English

如何在ZF2的每个页面上运行功能

[英]How to run a function on every page in ZF2

I'm new to ZEND so go easy, I have a menu table set up in mysql called menu_table, how do I run a function on every page to select * from that table and then pass it through to Module/Application/View/layout/layout.phtml 我是ZEND的新手,所以简单一点,我在mysql中设置了一个名为menu_table的菜单表,如何在每个页面上运行一个函数来从该表中选择*然后将其传递给Module / Application / View / layout /layout.phtml

Many thanks 非常感谢

The best practice in this case would be to create custom View Helper to get all menu items from the menu_table. 在这种情况下,最佳做法是创建自定义View Helper以从menu_table获取所有菜单项。

  • In custom View Helper you have to inject service or mapper with method to get all data 在自定义View Helper中,您必须使用方法注入服务或映射器以获取所有数据
  • Custom View Helper should call from layout.phtml Custom View Helper应该从layout.phtml调用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM