如何在ZF2中的每个页面上运行一个函数

时间:2021-03-09 01:09:23

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

非常感谢

1 个解决方案

#1


0  

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调用

#1


0  

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调用