在Symfony 1.2.x管理生成器中过滤内容? [英] Filter content in Symfony 1.2.x admin generator?

查看:154
本文介绍了在Symfony 1.2.x管理生成器中过滤内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Symfony 1.2.7应用程序,其中3个不同的网站共存于同一个数据库。所有内容都有一个外键site_id,表示它属于哪个站点。

在我生成的管理界面中,我希望能够显示当前的内容(实际上是使用过滤器类设置的,基于用来访问管理界面的域)。

一个例子:

使用www.domain.com/admin/,用户可以访问属于domain.com域名(site_id = 1)和本网站的内容。



关于如何实现这个的任何想法?

预先感谢

解决方案

你可以在你的Content模块的generator.yml中使用table_method选项:

  config: 
...
list:
table_method:getSiteContent
...


$然后在你的Content_Table类中写一个修改查询对象的方法:
$ b $ pre $ public function getSiteConten t(Doctrine_Query $ q){
$ q->和其中(某些情况下用site_id);
return $ q;
}


I have a Symfony 1.2.7 application where 3 different sites coexist in the same database. All content has a foreign key, 'site_id', that says which site it belongs to.

In my generated admin interface I want to be able to show content from the currently selected site (actually set using a filter class, based on the domain used to access the admin interface).

An example:

Using 'www.domain.com/admin/', the user has access to content belonging to the 'domain.com' domain (with site_id=1) and this site only.

Any ideas on how to achieve this?

Thanks in advance

解决方案

you can use table_method option in the generator.yml of your Content module:

        config:
...
          list:
            table_method: getSiteContent
...

then write a method in your Content_Table class that modifies the query object:

public function getSiteContent(Doctrine_Query $q) {
        $q->andWhere( some where condition with site_id );
        return $q;
}

这篇关于在Symfony 1.2.x管理生成器中过滤内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆