简体   繁体   中英

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

Many thanks

The best practice in this case would be to create custom View Helper to get all menu items from the menu_table.

  • In custom View Helper you have to inject service or mapper with method to get all data
  • Custom View Helper should call from layout.phtml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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