在Symfony 1.2.x管理生成器中过滤内容? [英] Filter content in Symfony 1.2.x admin generator?
问题描述
在我生成的管理界面中,我希望能够显示当前的内容(实际上是使用过滤器类设置的,基于用来访问管理界面的域)。
一个例子:
使用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屋!