douyu7618 2014-06-06 07:24
浏览 31

Zend Framework 2在模板视图中获取操作和id

How to get action name and value of id in template view (index.html). Need to insert action name in <h1> ... </h1> and use id value to select current option in menu.

My route:

 'route' => '/:action[/:id]',
 'constraints' => array(
     'id' => '[0-9]+',
     'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
 ),

Content of the index.html:

<h1>... </h1>

<div class="menu">
      <a href="#"> option where ID = 1 </a>
      <a href="#"> option where ID = 2 </a>
      <a href="#"> option where ID = 3 </a>
</a>
  • 写回答

1条回答 默认 最新

  • doujia1939 2014-06-06 09:32
    关注

    You can do it by making a view helper as dominic watson has answered in this question Dominic Watson Answer for creating view helper to get controller name in view OR

    more easy answer would be available at

    ZF2 Access controller name/action from layout

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?