简体   繁体   English

如何在Symfony 1.4后端模块中保持GET参数有效?

[英]How to keep a GET-param alive in Symfony 1.4 Backend-module?

I built a SF 1.4-backend-module, which needs to be kind of "pre-filtered". 我构建了一个SF 1.4后端模块,该模块需要进行“预过滤”。 So I added the GET-parameter ?type=A to the menue-link. 所以我在菜单链接中添加了GET参数?type = A。

Now I need to "keep this param alive" within the module when clicking on "edit", "delete", ... 现在,当我单击“编辑”,“删除”,...时,需要在模块中“保持此参数有效”。

Is there an easy way to keep this get-param all within the module or even a better way to pass a fixed value to the module? 有没有一种简单的方法可以将此get-param保留在模块中,甚至可以提供一种更好的方法将固定值传递给模块?

Instead of using a get parameter, which doesn't always work, you should better store this information into the session. 代替使用不一定总是有效的get参数,您最好将此信息存储到会话中。 Filter are getting from the session and from the form (when you submit it). 过滤器是从会话和表单(提交时)获取的。

For example, if you want to filter by author on the book listing a certain FK, use this snippet before going to the page or in the preExecute() of book: 例如,如果preExecute()列出某个FK的书中的作者进行过滤,请在转到页面或书的preExecute()中使用以下摘录:

$this->getUser()->setAttribute(
  'book.filters', 
  array('author _id' => $author->getId()), 
  'admin_module'
);

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

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